Creating an agent for overdue tasks

(Dominique Renauld) #1

Hi! I’ve been working on a new Tinderbox file for several weeks now.

I called it “Carnet de projets” (projects notebook) and it works perfectly. I am looking for some piece of code which would work for coloring all my overdue tasks, but, whatever I do, I can’t find the good one. I created the following agent to identify quickly my urgent tasks:


But, what about overdue tasks ?
Thanks for your answers.

(Mark Anderson) #2

For agent queries, don’t forget to use ‘==’, so your urgent agent’s query is better written as $Urgent==true.

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.

(Stephen Zeoli) #3

I am planning to make this exact kind of procedure part of my next video tutorial. It helps to see your reply to confirm my procedure.

How to create a recurrent task?
(Dominique Renauld) #4

@mwra Thank you Mark for your answer. It works very well. @StephenZ Great!