Tinderbox Forum

Removing alias from an agent after a certain age

I’m sure there is a simple way to do this, but I’m fairly new to using tinderbox extensively and am stuck.

I currently have an agent that grabs everything with the prototype task card

$Prototype==“Task Card”

which dumps everything into a simple kanban board I have created which is called aKanban

within the agent aKanban I have four adornments: waiting, open, doing and done.

When I move one of the tasks to the done adornment a simple OnAdd marks the task as complete with a completion date.

All good so far.

Except for after awhile, as I’m sure you can imagine, the done adornment ends up covered with old completed tasks. Deleting the alias, as you would expect, only prevents the task from being visible until the next agentquery cycle.

I’m hoping I can change the original aKanban agent query to be something like

$Prototype==“Task Card” AND completion date is less than 7 days old (obviously the syntax is wrong, that’s where I am stuck) so that after 7 days, any task that is completed will no longer be visible in in the aKanban agent

I hope that makes sense and thank you for your time.

HI Jorge,
Welcome to the forums. I’m myself new to TB so others will provide a more comprehensive answer.

Assuming you are capturing date in user attribute called $completedate, We can try a query which says

$Prototype==“Person”&date(“today”-7)<$completedate;

See the attachment where I’ve created a Prototype and sample dates
PS : My file has reverse data (it shows tasks which were completed 7 days back)

Jorge Example.tbx (102.1 KB)

Thanks to @pmaheshwari for offering us a model we can work from. Building from this, I’ve made a new version: Jorge Example2.tbx (108.1 KB)

In it I’ve used $DueDate in both an agent and an adornment. The Adornment shows the map function as asked for. The agent is better used in the Outline tab, where I’ve also turned column view on to show $DueDate to make the query’s comparison easier to cross-check. I wouldn’t do the latter in real use, but it is the sort of think that is useful in small test docs like this.

Jorge Example2.tbx 2021-01-19 09-54-43

The query for both the agent and adornment is:

$Prototype=="Task Card" & $DueDate<date("today - 7 days")

As regards the date() arguments, you will see from @pmaheshwari’s example that date("today" - 7) works. Tinderbox thankfully assumes the ‘7’ refers to a number of days and not year or seconds, etc. When experimenting/learning I find it useful to be explicit plus a year later you will know what you meant if reviewing the code. Note too that the date ‘calculation’ is all in the same string (see more on the syntax for this).

Some other stylistic notes:

  • Prototypes don’t use a semi-colon delimiter at the end. It will be safely ignored if you do, but ideally omit one. Yes, it is action code. But it is also a single action code expression. (Rules, etc., only need a semi-colon terminator when there is not than one expression in the overall code, though by convention we write single expression actions with a semi-colon at the end.)
  • Although completedate is a perfectly valid user attribute name, Tinderbox convention is to use capitals and inter-capitals, as in Complete or CompleteDate. The convention is not a requirement but it helps align you code use with the majority of code samples and tutorials and makes it less likely you will have an attribute name being mistaken for literal text. See more.
1 Like

I’ve learned much more before I replied to post. Thanks @mrwa . Great to know about the date calculations and stylistics notes

1 Like

Thanks. I always find it hard to make such observations without it seeming like pedantry or critique, which of course is not my intent. The flip side is that most of these things aren’t obvious before you know, so I think pointing the out helps—even if only for later readers. :slight_smile:

It really really does help when someone experienced takes time and effort to educate, it’s really easy to pick up something like “today”-7 and then thinking that TB will only calculate days , I legit have a file where I’m doing “today”-120 because I didn’t think simply writing “today-4 months” will work.

1 Like

thanks so much for the replies @mwra and @pmaheshwari. It still doesn’t seem to be working as expected and I think I know why. using the following AgentQuery:

$Prototype==“Task Card” & $completed<date(“today - 7 days”)

Will only provide notes that have both the Task Card prototype AND those that have been completed anytime in the last 7 days. By default, the $completed attribute is null or empty or I suppose false would be the proper syntax. and since that isn’t covered by the AgentQuery none of the to be completed notes show up.

I imagine I need some sort of if/than statement, if that’s possible.

thanks again for the help

OK, I’ll assume $completed is a date-type attribute . If it is not set the default value, for a Date-type attribute is the string value “never”. Checking in my earlier demo file and adding a ‘Task Card’ note with $DueDate not set (i.e. “never”), the agent doesn’t match it. You don’t specify but is this what you want to happen. You say the result in not as expected but not what you expect! :slight_smile:

. Note, I do think Completed or CompletedDate would be a more sensible name for reasons already explained above