Is there a way to get the value of a placeholder from AppleScript?

Hi all,

I’m trying to process/get the value of a given standard placeholder and put it into a variable in an AppleScript for further processing. As example, I want to get the value of %sortableDate% and store it as a string. I know that in this case it is possible to just recreate it using current date and concatenating strings but I’m bothered by longer-than-necessary scripts and the fact that my reimplementation could eventually diverge and break the script.

I’m thinking if something like this would be possible?

set valueOfPlaceholder to placeholder "%sortableDate%"
-- valueOfPlaceholder = "2022-08-15"

Sorry but not that’s not possible using placeholders. Once the placeholders has been resolved to its value, there is no more reference to that placeholder. So %shortDate% ≠ 08-15-2022; it's just 08-15-2022` at that point.

If I understood you correctly I think that is what I expect here. I’m not looking for a dynamic placeholder-variable that is resolved as it is used, just a resolve-this-placeholder-right-now-and-store-the-results kinda operation.

Maybe a clearer example is using my current workaround, it gets the equivalent value as the sortable date placeholder from a shell script:

-- Searches for a YYYY-MM-DD.md note in a group
		set noteName to do shell script "date +%F"
		set existingNote to children of theGroup whose name is noteName and type is markdown

What I’m wondering if it is possible is a version of this that can be used to resolve any of DT’s placeholders, something like set noteName to placeholder "%sortableDate%"noteName would be the resulting string from the placeholder result.

No, this isn’t possible either as the values for the placeholders are generated dynamically whether being used in a smart rule, batch processing, template, etc.

Actually most values of placeholders are available via the properties of databases & records, converting & formatting them to the desired format is up to the script though but usually doesn’t require much code.

1 Like

Yep, and my own example shows how easy it is to “workaround” it. Don’t get me wrong this was just a question of current availability, in case I was missing something, and not a request to add support to the feature—I don’t even have use cases where it would make a real difference to have it.

And perhaps I’m misunderstanding how you’d actually implement this in a real life situation.