State to Closed Complete in when moving to Done Column in VTB

Shree Nag
Tera Expert

Hello All,

Appreciat your help in advance.

 

I have created a business rule to change the state of the tasks to Closed complete when tasks are moved to Done column in VTB.

I'm not seeing the state being updated. Attached is a screen shot of the is the business rule that I have created. Please do let me know , what Am'I missing here? Please help.

 

The script is :

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

 
            var ptaskGR = new GlideRecord('vtb_task');
            ptaskGR.get(current.task.toString());
            ptaskGR.setValue('state','3');
            ptaskGR.update();

})(current, previous);

 

 

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Shree Nag 

you should query the task table

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


var ptaskGR = new GlideRecord('task');
ptaskGR.get(current.task.toString());
ptaskGR.setValue('state','3');
ptaskGR.update();

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Shree Nag
Tera Expert

Hello Ankur,

Thank you for your reply.

I implemented your script. But when I move the card to Done column, the card disappears from the lane giving a message, the card no longer matches the board criteria and removed from the board. It should stay in done column, when teh state is set to closed complete.

Please let me know what could be wrong.

Hi @Shree Nag,

 

This is most likely due to a condition to remove cards on the VTB based on Card State.