The CreatorCon Call for Content is officially open! Get started here.

Why is my event Failing to Trigger an Action Script to gs.info a string?

Josh101
Giga Contributor

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.

1 ACCEPTED SOLUTION

Josh101
Giga Contributor

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');

 

 

View solution in original post

8 REPLIES 8

vkachineni
Kilo Sage

//Try without name=

gs.eventQueue('x_lomo_lmcmdbint.Custom-Applications-App',current, 'This is Param Onezzzzz', 'This is Param Twozzzzz');

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Returns the same issue

 

Are the Event, Action script and the BR in the same application scope?

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Yes, all three are in the same scope.