In my previous article, I talked about automating labels/tags in ServiceNow and the problems when using dot-walking.
In this one, I explore the possibility of fixing that, while implementing a feature that should exist out of the box: filtering unassigned tasks in a Visual Task Board.
Creating the label
In the Visual Task Board, create the label “Unassigned”.
Automating the labels for the Visual Task Board Card
Create a new Label table [label_table] record.
Title: Unassigned task
Table: Visual Task Board Card [vtb_card]
Condition: Task→Assigned to is empty [task.assigned_toISEMPTY^EQ]
Notice that we assign the Label to the VTB Card, not the actual task.
Link the Label table[label_table] to the Label [label] record under “Conditions for Labels”.
And now you can filter unassigned tasks!
As I explained in my previous article, this is great, but it only works when you link the Label table and the Label if you are using dot-walking in your condition.
When you update a Story, the label is not added/removed to/from the VTB Card unless you update the VTB Card too (e.g. changing lanes).
The initial setup is created by the Business rule “Label Auto Assignment”.
But I couldn’t find the code that updates the labels dynamically.
It behaves like a Scheduled job triggered every few seconds, but it seems to be a black box.
So we need to find alternatives.
Warning: This is just a proof of concept in a PDI! You might not want to run this code for all your tasks in a production environment!!!
At least, set some conditions and narrow it down to the specific set of tasks (filter by task type, group, dashboard, etc.).
In an async business rule on the Task table, we can force the update of all related Visual Task Board Cards.
We don’t change anything in the record, we just force the update.
Then, the out of the box functionality will be triggered after a few seconds and the tag will be assigned/removed.
Same idea. Forcing the update of VTB Cards related to updated tasks, but you only run it every few seconds/minutes.
In the following GIF, you can see how the label/tag is automatically added/removed (it takes a few seconds).
No need to update the VTB Cards manually!