Remove Tags from Virtual Task Board

stevezempke
Tera Contributor

I have a Visual Task Board from our Incident table and the lanes on the board are by assignee.  I have created business rules to add tags to the cards on the board when the state of the incident ticket changes from New to Assigned to Work in Progress, etc.  However, my challenge is to remove the tags when the state of the incident changes.

for example, is a ticket is New i give it a Red tag (dot).  If the ticket moves from New to Assigned i give it a Blue tag (dot).  When I change the state to Assigned, the Red tag (for New), stays on the card and doesn't get removed and the goal is to have it removed.

Since the card isn't changing lanes, as the incident is assigned, the incident stays in one lane, and the state of the incident can change, how can i remove the previous tags when the state field changes and show only one tag on the ticket representing the current state of the incident and not previous states.

Thanks in advance for your help.

1 ACCEPTED SOLUTION

So in your case, you can have two business rules or flow whichever is convenient

1. When the state is in New

2. When the state changes from New to In progress

In these cases, you don't have to worry about deleting the entry instead try to update it.

Below is an example of a BR when the state changes to "In Progress". I assume you are using the OOB state, if you have an additional state then choose the condition accordingly. The BR can be written on the Incident table provided you have the same exact filter condition used in the VTB guided board. 

I have a vtb where the condition is just assignment group is the service desk. So that is my condition along with that the state changes condition. 

find_real_file.png

In the advanced tab here is the script I used. Here I know the label sysid in 2nd line already its a static one and the new label which I am going to update in line 5. 

(function executeRule(current, previous /*null when async*/ ) {

    var grLabelEntry = new GlideRecord('label_entry');
    grLabelEntry.addEncodedQuery("label=324eb2da2f034110379a5e072799b64a^table_key=" + current.sys_id);
    grLabelEntry.query();
    if (grLabelEntry.next()) {
        grLabelEntry.label = '4eb2da2f034110379a5e072799b6432a';
		grLabelEntry.update();
    }

})(current, previous);

Similarly, you can write a BR for the new state. Let me know if it helps. 

Thanks,

View solution in original post

10 REPLIES 10

Muralidharan BS
Mega Sage
Mega Sage

Tags are stored in table [label] any record associated with the tag is stored in [label_entry] table. write a BR or Flow to just delete the record in label_entry table. you can amend the condition to match your need. 

 

Thanks Murali.  I have a BR that i think does the delete, in the script part anyway, but would the BR be a before/after?  Also in the filter conditions, i know to look for the board to do the changes against, but the lanes on the board are by assignee of incident tickets.  when the state of the incident changes, say from Assigned to WIP, that is when i want to remove the Assigned tag and add the Work in Progress tag.  I can add the tags just fine, as the state of the incident changes, but with the removal based on the changing of the state of the incident, not the changing of lanes on the board, what would my filter conditions be in this case?

(function executeRule(current, previous /*null when async*/) {

 var record = new GlideRecord('label_entry');
 record.addQuery('table_key', current.sys_id);
 record.addQuery('label', 'ad802809db200010dfcadde748961955');
 record.query();
 if (record.next()) {
    record.deleteRecord();     
 }

})(current, previous);

in a long ago previous post, you posted this script to delete records from the label_entry table.  i've tried this several times, with many variations, and nothing ever gets deleted from the file.

 

in the filter conditions, what would be my logic to look at a board, which i know the name, and if the state field on the incident ticket changes.

once the filter logic is met, i then need to delete all records from the label_entry table that pertain to that board name and the assignee, as that is how the board is sorted, is by assignee of the incident ticket.

so if an incident state moves, say from New state to Assigned state, and i have a red dot on the card for New state, and i update the state of the incident ticket to Assigned state, which is a blue dot, i want to have the business rule delete the label_entry record for New state entry and create a new entry for Assigned state, which with the deletion of the New state record from the label_entry table, the red dot goes away from the vtb card and with the creation of the Assigned state record in the label_entry table, a blue dot appears on the vtb card for that incident.

everytime a state changes on an incident, i need the business rule to delete any previous label_entry records for that incident for any previous states, and only create one record in the label_entry table for the latest change in incident state.

sorry for being wordy but i hope i'm explaining my issue in detail and what i am trying to do.

So in your case, you can have two business rules or flow whichever is convenient

1. When the state is in New

2. When the state changes from New to In progress

In these cases, you don't have to worry about deleting the entry instead try to update it.

Below is an example of a BR when the state changes to "In Progress". I assume you are using the OOB state, if you have an additional state then choose the condition accordingly. The BR can be written on the Incident table provided you have the same exact filter condition used in the VTB guided board. 

I have a vtb where the condition is just assignment group is the service desk. So that is my condition along with that the state changes condition. 

find_real_file.png

In the advanced tab here is the script I used. Here I know the label sysid in 2nd line already its a static one and the new label which I am going to update in line 5. 

(function executeRule(current, previous /*null when async*/ ) {

    var grLabelEntry = new GlideRecord('label_entry');
    grLabelEntry.addEncodedQuery("label=324eb2da2f034110379a5e072799b64a^table_key=" + current.sys_id);
    grLabelEntry.query();
    if (grLabelEntry.next()) {
        grLabelEntry.label = '4eb2da2f034110379a5e072799b6432a';
		grLabelEntry.update();
    }

})(current, previous);

Similarly, you can write a BR for the new state. Let me know if it helps. 

Thanks,