I am having issues with the gr.state.changesto(3) in the BR

Ricardo Sanche3
Tera Contributor

The condition works fine with the short description but when I add it to check the state is not working. I want to check this task and when the state changes to closed complete

 

 

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

 

var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.query();
if (gr.next() && gr.short_description == 'Complete eSign Document Process' && gr.state.changesTo(3)) //any value to compare
{
answer = true;
gs.eventQueue('ccu.wfh.approval', current, '', '', '');

} else {


answer = false;


}


})(current, previous);

2 REPLIES 2

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Something like "gr.state.changesTo" won't work. Something like "current.state.changesTo" could work (depending on the type of Business Rule).

 

What you are after, will simply not work.

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Manmohan K
Tera Sage

Hi @Ricardo Sanche3 ,

 

As pointed by @Mark Roethof  - the "gr.state.changesTo" won't work . As a work around you can shift your business rule to sc_task and have conditions like below to send event

 

ManmohanK_0-1685474624469.png