Having trouble scripting reminders

Hi all!

I’m setting up an import of bills to a DT3 database. I want to include the reminder for the due date when the bill is imported.

Currently, the due date is in the file name, which is then matched by Hazel. Hazel then runs this script (where inputattribute1 is the matched due date):

set DD to inputattribute1
set databaseOpen to true
set DB to “Business”
set dest to “/Finances/Processing”
tell application id “DNtp”
if DB is not in (name of databases) then
set databaseOpen to false
open database “DATABASE PATH”
end if
set destinationGroup to get record at dest in database DB
set newRecord to (import theFile to destinationGroup)
set tags of newRecord to {“bill”}
set reminder of newRecord to {due date:DD}
if not databaseOpen then
close database DB
end if
end tell

The bolded line isn’t working, am I messing up the syntax somehow? Can a dated reminder be added this way?

Here’s a simple example adding a reminder for tomorrow:

	tell application id "DNtp"
		set due_date to current date
		set due_date to due_date + 3600 * 24
		repeat with theRecord in (selection as list)
			tell theRecord to make new reminder with properties {schedule:once, alarm:notification, due date:due_date}
		end repeat
	end tell
1 Like

Thanks - is there any way to make that work within my script? I’m working with a new record… so nothing is selected in DT.

Just replace the bold line in your script with the one that you’ve quoted from my example and change theRecord to newRecord (and due_date to DD):

tell newRecord to make new reminder with properties {schedule:once, alarm:notification, due date:DD}

Thanks - I’m starting to suspect the issue lies with the input, because that is what I tried.

I’ll do some more research on how to format it better, I’m assuming DT requires a time?

A time shouldn’t be necessary. Does DD contain actually a string or a date? In case of a string it has to be converted first to a date.

Here’s a simple snippet…

set r to "7.23.2020 8:00am"
set alarmDate to (date r)
--> date "Thursday, July 23, 2020 at 8:00:00 AM"