Email Notification Sending When Condition is Not Met

Nick Peters
Tera Guru

I have 2 emails with the following settings:

Email 1
Email 2
Send when: Record inserted or updatedSend when: Record inserted or updated
Inserted: trueInserted: true
Conditions: NoneConditions: Requested for is different from Requested by
Recipients: Users/Groups in fields: Requested byRecipients: Users/Groups in fields: Requested for

Requested by and Requested for are reference fields to the User [sys_user] table. They are populated with a user via a before Business Rule that executes on insert of a new record on this same table.

My problem is that both emails are sending when the Requested by and Requested for are the same user; only Email 1 should be sending in this situation.

I have tested this using a weight of 0 on both, 10 on both, and 10 on Email 2 & 20 on Email 1. I have used this same condition logic for emails on other tables and those have always been working as intended. It should be noted that these emails (and the Business Rule) are in a scoped application.

1 ACCEPTED SOLUTION

Nick Peters
Tera Guru

While we were never able to determine why the condition wasn't working as intended, we were able to achieve the desired result by removing the condition from the condition builder and instead scripting the condition using the advanced condition script. The code is as follows:



answer = reqByReqForSame();



function reqByReqForSame() {


  if (current.u_requested_for.sys_id.toString() == current.u_requested_by.sys_id.toString())


            return false;


  else


            return true;


}


View solution in original post

9 REPLIES 9

I have checked the audit log and confirmed that the Requested by and Requested for fields are set via the Business Rule once and do not change.



I am experiencing the same issue for the email(s) that are sent when the record state changes to "Cancelled". Again, it is sending both emails to the same user even though one of the emails has the condition of:



Requested for is different from Requested by



So we can eliminate the possibility that the fields are not being set from the beginning. The only thing changing on the record when it is cancelled is the state.


Rajshekhar Pau1
Kilo Guru

Hello Nick,



Could you please check once with the option of Preview Notification on the top right corner of this email notifications(Email 1 and Email 2 in your case). You can have a look from there for a respective record(RITMxxxxxx), that whether the recipients will receive the emails or there is any issue.



PFB screenshot:



find_real_file.png


Hope this helps.



Please Hit Like or mark Helpful or Correct based on the impact.



Thanks,


Rajshekhar Paul


oharel
Kilo Sage

Can you post a screenshot of the first tab of your notification?


I am guessing it has to do with the conditions somehow.


harel


Nick Peters
Tera Guru

While we were never able to determine why the condition wasn't working as intended, we were able to achieve the desired result by removing the condition from the condition builder and instead scripting the condition using the advanced condition script. The code is as follows:



answer = reqByReqForSame();



function reqByReqForSame() {


  if (current.u_requested_for.sys_id.toString() == current.u_requested_by.sys_id.toString())


            return false;


  else


            return true;


}


This weird behavior was seen by me too. But I just added a random log or comment statement in the advanced conditions script and viola the Notification starts to work with the original conditions in condition builder