Additional Comments Notification Triggering Twice

mamathag
Tera Contributor

I have a requirement to send notification to requester whenever we are updating additional comments on RITM form.

We have 'Restore' and 'Cancel Button' on the form.Upon clicking on these buttons we are making comments mandatory and after filling

comments we are clicking button again and moving further.

In this scenario the notification is triggering twice to the user. Rest all scenarios are working fine where we are updating comments normally.

Why it is taking the comments update as two times even though I am updating it once.

Can anyone help me to understand the reason for this issue?

Please find one of the ui action script below:

function cancelRequest(){

var submitFlag= confirm("If you cancel request, workflow will be stopped");

if(!submitFlag){

return false;

}

g_form.setMandatory('comments',true);

gsftSubmit(null, g_form.getFormElement(), 'cancel_ns_TP'); //MUST call the 'Action name' set in this UI Action

}

if(typeof window == 'undefined')

runBusRuleCode();

function runBusRuleCode(){

current.approval='cancelled';

current.update();

action.setRedirectURL(current);

}

4 REPLIES 4

oharel
Kilo Sage

Is the same email sent twice? If no, find the other email source notification and check its conditions.


If yes, check the events log and see how many times the event is triggered and which email is created within it.


If you see only one event log record and one email, check the notifications related to the table, to see if they have a condition to send on comments update/change.



Your UI action does not trigger the notification as of itself - you don't have a gs.eventQueue line in there, but maybe the approval change of state to cancelled triggers the duplicate email.



harel


mamathag
Tera Contributor

Hi Sheffer,


The same email is triggering twice. I don't have any events created for this. I am just writing direct notification on 'additional comments — changes'.


shloke04
Kilo Patron

Hi,



I assume you are triggering your notifications based on the condition as "If Record is updated" & Comments field changes you are firing the notification which should be the reason it's getting triggered twice.



I would recommend to use event to fire your notifications in both the places in your BR as well as in the UI action which would make sure the Notification gets fired separately based oneach condition either if you are updating it normally on the form itself or updating the comments field based on when you are clicking on the UI action.



You can use the below mentioned API to fore an event from any server side script:



gs.eventQueue('even_name', record, param1, param2);



Refer the below thread which gives an example on how to use event to fire an notification. In the example event is fired through an scheduled job, you can use it in your BR or in an UI action.



Fire an email notification from a schedule job



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Srivastava,



I tried with event from BR as you mentioned but no luck.


But I could able to fix it when I trigger event from 'cancel button' ui action directly instead of BR.



So as a solution I created BR and triggering event for all the scenarios except cancel request and restore.


For cancel and restore I am triggering it from respective ui actions itself.


It is working.



But I couldn't find out the actual reason for triggering twice.