For agent queries, don’t forget to use ‘==’, so your urgent agent’s query is better written as
Colouring overdue tasks, I’m going to assume:
- Your events use prototype “Event”.
- Your events have a due date set (in $DueDate)
- Completed events are marked using $Checked, i.e. ticked on-screen (so $Checked==true).
- We will set $Color to ‘red’ for overdue items.
Of course if you use a different date attribute for due date, or mark item complete a different want or want to mark overdue items with a badge/different colour/etc. you can just change the relevant code. If you don’t use a prototype, just ignore the first part of the query - the aim is to avoid not testing more notes than we need to, as a matter of efficiency.
The agent query needs to find all Events, which are not complete and where $DueDate is before the current day. As a start we could try:
$Prototype=="Event" & $Checked==false & ($DueDate < date("today"))
But Date attributes are date/times and at midday we probably don’t want items due today and with a before-12:00 time to make as overdue. Working on a day granularity seems better, so:
$Prototype=="Event" & $Checked==false & days(date("today"),$DueDate ) < 0
This new agent will not match an item that is due at any time today, the comparison uses the days(date1,date2) operator. So, that is the agent’s query.
For the action, just set the desired attribute(s):
Note in the action we use one ‘=’ to set an [attribute] equals [value], but in the query we use two ‘==’ to test [attribute’s current value] is exactly equal to [value]
Things to consider. The code above answers the question in simple terms. But consider things like overdue items that get a new (future) due date, i.e. get a new deadline. You could reset the $Color manually when changing the due date, to you could write more code to handle that task. My advice is to not do the latter until you find you really need to. that avoids adding yet more code you may not really need.