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

Alikutty A
Tera Sage

Hi Nick,



Please try a weight of 0 on Email 1 and 100 on Email 2 and see if it works.



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


I apologize, I forgot to state that I had tried that configuration. I have tried with one email having a weight of 0 and the other with a weight of 10. Still had the same result.


Hi Nick,



Try to print requested by and requested for in email body and share the result for email2.


oharel
Kilo Sage

Also, check the records themselves - their activities - and see if they the record that matches email 2 actually gets created with requested for = requested by and then the requested for (or by) is changed after a few seconds.



harel