Triggering event from Business rule

munwala
Kilo Contributor

Hi All,

I am trying to trigger an event within a Business rule. For that, I am using the Advanced section of the business rule where I have my conditions in the condition field as 'current.substatus.changes() && current.substatus == "pending_disposal"' and then I have a function within the script block:

sendEmailOnChnageOfSubstate();

function sendEmailOnChnageOfSubstate(){

gs.eventQueue ("name_of_event", current, null, null);

}

And then I have a notification which fires my event and that notification has a email hard-coded within the body.

The above code is not running.

Can anyone help me modify it so that it runs fine. Appreciate your help.

Thanks,

1 ACCEPTED SOLUTION

I created this:


Capture.PNG


Capture2.PNG



and got this:


Capture3.PNG



Is this how you are set up?


View solution in original post

12 REPLIES 12

Mike Allen
Mega Sage

You could do current.substatus.changesTo("pending_disposal")



Check to make sure substatus is the actual name of the field.   What is the table?



Your event is registered, right?



Other than that, it looks good.


Hi Mike,



Yes substatus is the correct field name on alm_asset table.


Yes I have my event registered.


I will try you code and see if it works.



I am not sure if I need to call my function in the condition field?



Thanks,


No, it would be in the script field:



sendEmailOnChnageOfSubstate();



function sendEmailOnChnageOfSubstate(){


        gs.eventQueue ("name_of_event", current, null, null);


}


I have the exact same thing its still not working