AppleScript: adding date to metadata field fails

Sorry—back again!

I have a custom metadata field called “Diary entry date” (with the identifier “diaryentrydate” and both type and format set to date). I am trying, in a script, to write to that field…without success.

The relevant parts of my code are:

--format date for adding to custom metadata
set {day:d, month:m, year:y} to (current date)
set metadataDate to d & "/" & (m as number) & "/" & y

and

add custom meta data metadataDate for "diaryentrydate" to myRecord

I have tried both the identifier and the text “Diary entry date” in the custom meta data command. In both cases the script passes gracefully over the command without error and does nothing.

What have I done wrong this time?

Stephen

This is a string but depending on the setup of the custom metadata field a date is probably required.

A date is certainly required. I was trying to format the thing as a date but clearly failed!

Stephen

E.g. this should work:

set theDate to current date
add custom meta data theDate for "diaryentrydate" to myRecord

Many thanks: most kind—shall meddle further with the script!

Stephen

Absolutely perfect: thank you!

Stephen

You’re welcome.