I am having issues with the gr.state.changesto(3) in the BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 11:51 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 11:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 12:24 PM
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