- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 05:07 PM
I'm having a similar issue.
Before Business rule triggers on Delete of CI on cmdb_rel_ci table. And successfully creates an Event, I have confirmed by checking the Events table.
(function executeRule(current, previous /*null when async*/ ) {
gs.info('Event Created');
gs.eventQueue('x_lomo_lmcmdbint.Custom-Applications-App',current, 'This is Param Onezzzzz', 'This is Param Twozzzzz');
})(current, previous);
I have an Action Script Set to trigger (in Global Scope) that runs the code below when this type of event is triggered.
try {
var eventParam1 = event.parm1;
var eventParam2 = event.parm2;
gs.error('Script Action Triggered');
gs.info(eventParam1);
gs.info(eventParam2);
gs.info('Script Action Ended');
} catch (error){
gs.error('Script action failed');
gs.error(error);
}
This does not get logged anywhere, which indicates to me that it is failing to rigger.
Both the Business Rules and Action Script are in the same Scoped Application context.
The generated Events, Business Rule and Action Script are all created and run by the same user, me.
What am I missing here? Why is the event not triggering the Action Script?
Any help would be much appreciated.
Update
I noticed that the state of all my events shows as "error". I'm not sure why yet. Whatever is causing that is likely the culprit.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2020 10:00 AM
Found the cause. I was passing the current context to the event inside of an On Delete business rule. The problem is that the current object that gets passed to the script action does not exist since it is really just a reference to the record that was just deleted.
Basicaly is a current/previous context object get passed from an Event to a Script Action when the original record for that current/previous context object get deleted, it will cause the Script Action to silently fail no matter what is in the code section of the Script Action. Instead of passing a context object to the gs.eventQueue(), I simply pass in null like shown below.
gs.eventQueue('x_lomo_lmcmdbint.Custom-Applications-App',null, 'This is Param Onezzzzz', 'This is Param Twozzzzz');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 05:46 PM
//Try without name=
gs.eventQueue('x_lomo_lmcmdbint.Custom-Applications-App',current, 'This is Param Onezzzzz', 'This is Param Twozzzzz');
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 06:04 PM
Returns the same issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 06:11 PM
Are the Event, Action script and the BR in the same application scope?
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 06:32 PM
Yes, all three are in the same scope.