The below script is triggering incorrect Events for notification .. how can I fix it ?

Pooja Khatri
Tera Contributor

Hi All, 

 

I have written a business rule which is triggering multiple events in the single script , for every of the email notifications for request , task it is triggering event : normal_change.approval.inserted ... in ideal scenario , for isRequest function it should trigger : request.approval.inserted event for isSCTask it should trigger event : sc_task.approval.inserted and so on , I am not pasting down the entire script , but there is some issue with the below part of the code which is everytime triggering : normal_change.approval.inserted for any of the function call .

 

How can I fix the below part ?

 

if (current.state.changes() && current.state == 'requested') {
    var event = "";
    if (isRequest)
        event = "request.approval.inserted";
    else if (isSCTask)
        event = "sc_task.approval.inserted";
    else if (isStdChange)
        event = "std_change_proposal.approval.inserted";
    else if(isEmergencychange)
        event = 'approval.inserted';
    else if (isnormalchange)
        event = "normal_change.approval.inserted";
    else if (!(current.source_table == 'change_request' || current.sysapproval.sys_class_name == 'change_request'))
        event = "approval.inserted";

    if (event != "") {
        gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
        updateTask(current, current.approver.getDisplayValue() + " requested to approve task");
    }
}
5 REPLIES 5

You can change the script shared by me.

 

 


Thanks and Regards,

Saurabh Gupta