Good lord–you’re right!
Have you ever heard the story of the woman who cut the ends off her roast? I originally broke this part out and added the test (and a bunch of dialogs) trying to trace an issue where the reminder wasn’t getting created at all.
It turns out, the issue is the custom metadata–it has to happen after everything else (note sure why). But in all my troubleshooting (and sometimes just throwing code at the wall until anything worked), I made it way more complex than it needed to be, then forgot to go back in and simplify once I knew what the problem was.
Thank you.
The corrected sections of code:
--Get the Tickle Date
set mtTickle to tickle date of theMessage
and
tell application id "DNtp"
set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag), label:1, tags:devonTags} in message_group
set comment of theRecord to mtNotes
if mtTickle is not missing value then
tell theRecord to make new reminder with properties {schedule:once, alarm:alert, alarm string:(name & " is due today!"), due date:mtTickle}
end if
--Make sure you have created a custom metadata with the label 'mailtagsimportance' or update the script
--must be last part or others don't work
add custom meta data mtImportance for "mailtagsimportance" to theRecord