Dynamic tags
Dynamic tags can be used to automatically insert text, such as the current date and time or the current user's username or email address into a search expression or a metadata field, etc.
Where can dynamic tags be used?
This article explains where and how dynamic tags can be used.
- In metadata macros in actions
- In search expressions (as independent terms and phrases)
- In Marker conditions
Further details are below.
Available tags
Every valid dynamic variable is expanded to its value, which is usually used as a literal string. In search expressions, it may also be interpreted as a date/time value or number.
For a list of dynamic variables and their usage, see:
Dynamic tags in metadata macros
If a dynamic tag appears in a metadata macro in an action, then it is expanded when the action is run.
Metadata macros allow additional dynamic tags which expand to metadata of the assets processed by the action or parameters of the action or task:
For backward-compatibility, some additional tags that expand to the current date and time are available in metadata macros. Some tags behave differently when used in metadata macros. For more information, see Legacy Date/Time Tag Reference.
Dynamic tags in search expressions
Dynamic tags can be used directly in search expressions in the following places:
- In the custom search string of a taxonomy item
- In the Search for field of the query of a SmartFolder
Dynamic tags in search terms
If a dynamic tag appears as an independent term (i.e., outside of double quotes), then its value is used as part of the search expression as if it was given literally. For example, consider the expression:
mt:{{now}}
The value of this tag is the current date and time in ISO 8601 format, for example,
2023-05-17T12:30:45
So the resulting expression will do the same as
mt:2023-05-17T12:30:45
i.e., search for all assets with a modification time of 12:30:45 on 17th of May, 2023 in local time.
If the dynamic tag has invalid syntax, then the entire search expression is malformed.
Dynamic tags in search phrases
A phrase (search text in double quotes) may contain multiple dynamic tags. When the search is executed, each dynamic tag is expanded to its value. For example:
mt:"{{now.date}}T{{now.hour}}:00:00"~~{{now}}
This expression searches for all assets that were modified since the start of the current hour until now. For example, it might translate to:
mt:2016-05-17T12:00:00~~2016-05-17T12:30:45
Note that the contents of the phrase on the left of the ~~
operator are interpreted as a date/time value. This is because it appears as an operand of a range operator. The left operand is created using two dynamic tags. One of them expands to the current date, and the other expands to the current hour.
If a dynamic tag in a phrase has invalid syntax or is invalid for another reason, then it is not replaced. All other tags are still replaced if they are valid.
How dynamic tags are interpreted in stored searches
If a search expression with a dynamic tag is stored - e.g. an expression using the date tag {{now}} - the tag will be resolved at the time of executing the search, not when it's stored. For example, this applies to searches in SmartFolders and taxonomy custom searches.
mt:{{now-P1D}}~~{{now}}
then contents of the smart folder are always the result of a search for all assets modified since the day before the current day.
Dynamic tag syntax
In general, a dynamic tag looks as follows:
{{[NAMESPACE.]ID[:ARGUMENT][+|-OFFSET]}}
where
Component |
Description |
Example |
---|---|---|
NAMESPACE |
The namespace (or category) of the tag. For example, the now namespace has tags that expand to the current local time. |
In the tag
{{now.date}}
the namespace is
{{now}}
does not have a namespace.
|
ID |
The id of the tag. Together, the (optional) namespace and the ID define what the tag does. |
In the tag
{{now.date}}
the ID is
{{now}}
the ID is |
ARGUMENT |
An optional argument following a colon. Some tags are parameterized, which means they require an argument. |
The tag
{{currentUser.property:Department}}
is a parameterized tag. It expands to the value of the |
OFFSET |
Some dynamic tags allow specifying an offset, which is always a time duration or a number. The offset may be positive or negative, which is indicated by a plus or minus sign that must precede the offset. If the offset is a time duration, then it must be given in ISO 8601 format, which is explained below. |
The tag
{{now+P1D}}
has an offset of "plus one day" and expands to the date and time one day after the current time. The tag
{{now.year-1}}
has an offset of minus one and expands to the number of the year before the current year. |