External and embedded script for reminder in DT3 only working when item is selected

I have a simple script I am trying to attach to a reminder in DT3. It duplicates a record in another folder and attaches a label. The script works when I select a record and run it as an external script manually, and it works as an embedded script attached to a reminder if the record is already selected when the reminder goes off. However, if the record is not selected when the reminder goes off, nothing happens (the reminder simply dings and resets for the next reminder time). It may be that the script is running, but without the record being selected it is not running on any actual record, in which case, I don’t know how to correctly ‘select’ the record activated by the reminder within the script.

The other strange thing is that I cannot get it to work as an external script attached to the reminder even when the record is selected when the reminder goes off. I copy it exactly and put the script in the ‘Reminders’ folder. I then have to restart DT3 for the new script to show up in the dropdown menu of available external scripts (if that could be fixed in the next beta, it would be great). I set it up to run an external script when the reminder goes off, but it won’t do anything when the reminder goes off. I can’t get it to behave the way the embedded script does.

The script is below:

on performReminder(theRecord)
tell application id “DNtp”
try
if ( exists content record) then
set theContent to content record
set theDatabase to current database
set label of theContent to 5
set theGroup to get record at “/__TO DO” in the database
duplicate record theContent to theGroup
end if
end try
end tell
end performReminder

Any tips? I would also ideally like to remove the reminder in the duplicated record (but not the original), but I don’t know how to do that.

There’s no need to get the content record or check if it exists. You already have theRecord as your reference.

As a hint: When you’re writing and debugging scripts, it’s best to leave try blocks out or log / display errors with on error.

Here is a rewritten reminder script:

on performReminder(theRecord)
    tell application id "DNtp"
	set currDB to (current database)
	set label of theRecord to 5
	set theGroup to (get record at "/__TO DO") in currDB
	if exists theGroup then
		set newRecord to duplicate record theRecord to theGroup
	else
		set theGroup to (create location "/__TO DO" in currDB)
		set newRecord to duplicate record theRecord to theGroup
	end if
	set reminder of newRecord to {}
end tell
end performReminder