- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 08:46 PM
We have a business rule which is scheduling one event in the event queue. The script action will run once that event is processed. And we have an event queue scheduled where we are processing the event after half an hour by using delay method in our business rule. The event is getting processed in the event logs but the script action is unable to call the outbound rest message.
Can you please help us why this is not working?
PS: Manual trigger of rest message is working fine
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:57 AM
If your instance is domain separated then Script action should be in global domain.
So just add this line in your script action
gs.info('My script action triggered');
If this log doesn't come then the issue is not with script
Other solution
1) make your BR as Async update and add the entire REST Message code inside BR
That should work fine
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 10:52 PM
update as this
BR
(function executeRule(current, previous /*null when async*/ ) {
var when = new GlideDateTime();
var delay = new GlideTime();
delay.setValue("01:30:00");
when.add(delay);
gs.eventQueueScheduled("Resolution_notification_dely", current, current.sys_id, "", when);
})(current, previous);
Script Action:
var rec = new GlideRecord('incident');
if(rec.get(event.parm1)){
var r = new sn_ws.RESTMessageV2('[HP OO] Incident Update', 'get');
r.setStringParameter('uuid', rec.correlation_id.toString());
r.setStringParameter('number', rec.number.toString());
var response = r.executeAsync(); //Might throw exception on request failure
response.waitForResponse(60); //wait up to 60 seconds
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus != 200) {
var s = new sn_ws.RESTMessageV2('[HP OO] Incident Alternate', 'get');
s.setStringParameter('uuid', rec.correlation_id.toString());
s.setStringParameter('number', rec.number.toString());
var response = s.executeAsync(); //Might throw exception on request failure
response.waitForResponse(60); //wait up to 60 seconds
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:16 AM
no it is not executing. Script action is only not executing. Do I need to delete any events from the logs or kill any previous sessions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:20 AM
Hi,
Delete the existing script action
AND
create fresh script action and add the code I shared
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:49 AM
Script action is working in my PDI but not here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:57 AM
If your instance is domain separated then Script action should be in global domain.
So just add this line in your script action
gs.info('My script action triggered');
If this log doesn't come then the issue is not with script
Other solution
1) make your BR as Async update and add the entire REST Message code inside BR
That should work fine
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader