Reminder extern script with smart rule

Hi,

I want to set a reminder in the reminder app via a smart rule. Is this possible?

Best regards.

Only by executing a script in the rule which adds the reminder.

Hi.
That’s what I did. But it doesn’t work. This is my test script:

on performSmartRule(theRecords)
	tell application id "DNtp"
		set due_date to current date
		set due_date to due_date + 3600 * 48
		repeat with theRecord in theRecords
			tell theRecord to make new reminder with properties {schedule:once, alarm:notification, due date:due_date}
			
		end repeat
		
	end tell
	
	tell application "Reminders"
		activate
		make reminder with properties {name:"Test", remind me date:current date, body:"Hallo"}
	end tell
end performSmartRule

I tested different things like "tell application “Reminders” in the repeat function. But this doesn’t work.

Each application uses a different syntax. Maybe this is helpful: https://macscripter.net/viewtopic.php?id=39312

Syntax works fine if I run script in DT at the Script menu. So I guess there is an issue running the syntax in a smart rule. Are there any restrictions?

Did you really use exactly the above script in the Scripts menu? Because this shouldn’t work at all.

In addition, unless you want a reminder in DEVONthink too the tell application id "DNtp" block is actually unnecessary.

No, just the syntax where I call Reminders App. Only this part.

And how does the smart rule look like? You can e.g. test its actions by dropping items onto it.

This is the smart rule:

What I found out now is:

  • I have to restart DT if I change the script. Even I save it in the right folder. Or did I something wrong?
  • If I comment out all the syntax making a reminder and just run the tell application “Reminders” syntax it works. It created a todo in the reminder app. But if I activate the other syntax it doesn’t work.
    But why?

This script works: But just comment out the first syntax. It seems I couldn’t have two tell-Commands. But this should work.

on performSmartRule(theRecords)
	(*tell application id "DNtp"
		set due_date to current date
		set due_date to due_date + 3600 * 48
		repeat with theRecord in theRecords
			tell theRecord to make new reminder with properties {schedule:once, alarm:notification, due date:due_date}
			set dok to reference URL as string
end repeat
		-- set titel to name
	end tell*)
	tell application "Reminders"
		activate
		make reminder with properties {name:"Rechnung Offen", remind me date:current date, body:"Test"}
	end tell
end performSmartRule

The scripts are cached while DEVONthink is running to improve the smart rule performance.

This line causes an error and stops the script:

set dok to reference URL as string

This should probably look like this:

set dok to reference URL of theRecord as string

That’s it! Great. Good start. Just beginner in Apple Script so I made this error. Thank you very much. Best app support ever.

Best regards.