Creating an item by smart rule

I’d like to create a simple document on a daily basis in a particular group:

(* tell application id "DNtp"
	set sel to (selection as list)
	my performSmartRule(sel)
end tell *)

on performSmartRule(theRecords)
	tell application id "DNtp"
		set theDate to date string of (current date)
		set theName to "Notizen " & theDate
		
		set theID to "6C86E6E5-DC88-45F5-9815-290BDE60E35C"
		set theGroup to get record with uuid theID
		set theMD to "# " & theName & return & return & return & return
		set theRecord to create record with {name:theName, type:markdown, content:theMD} in theGroup
		
	end tell
end performSmartRule

Running the script “manually” works as expected, but via smart rule it doesn’t execute and is impossible to debug. At least for a dummy. Any suggestions?

Why are you trying to do this as a smart rule?
This would be a better candidate for a Reminder.

This could be set to run on a daily interval on that particular group.

on performReminder(theRecord)
	tell application id "DNtp"
		set theDate to date string of (current date)
		set theName to "Notizen " & theDate
		set theMD to "# " & theName & return & return & return & return
		set newRecord to create record with {name:theName, type:markdown, content:theMD} in theGroup
	end tell
end performReminder

1 Like

Thanks, that works for me. I like.

You’re welcome.