- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 02:45 AM
Hi, I am trying to create a business rule that is triggered when a field is changed in a certain table.
The business rule is supposed to cancel the workflow running on a specific request that uses the record.
So the "current" is the record in the table which field I changed. The record also has a reference field to the RITM, so I tried to use it and stop the workflow running from the RITM. I get the error "input argument to Workflow Script API is not valid GlideRecord. Creating default current".
Adding my script:
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', current.u_request_number);
ritm.query();
var workflow = new Workflow();
workflow.cancel(ritm);
})(current, previous)
also tried canceling the context, also gave me the same error.
Anyone have any ideas? Thanks! 🙂
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 03:10 AM
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.u_request_number);
ritm.query();
if(ritm.next())
{
var workflow = new global.Workflow();
workflow.cancel(ritm);
}
})(current, previous)
Hope this helps
Mark the answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 02:51 AM
hello
try this in your script
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', current.u_request_number);
ritm.query();
if(ritm.next())
{
var workflow = new global.Workflow();
workflow.cancel(ritm);
}
})(current, previous)
Hope this helps
Mark the answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 03:03 AM
Still doesn't work, the state is still executing. But the error doesn't come up anymore.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 03:10 AM
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.u_request_number);
ritm.query();
if(ritm.next())
{
var workflow = new global.Workflow();
workflow.cancel(ritm);
}
})(current, previous)
Hope this helps
Mark the answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 03:29 AM
Thank you very much! It worked 🙂