- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 03:27 PM
I have an after-insert business rule that I want to use to trigger an email notification. The Notification's When to Send is Event is fired. The business ruIe runs to completion and prints the gs.info() statements as expected. I fire the event, but the notification does not run and no email is generated. What am I doing wrong?
Business rule
(function executeRule(current, previous /*null when async*/) {
var recipients = "";
var event = "x_acso_rf_poc.rf.sr.notification";
var property_root = "x_acso_rf_poc.rf.sr.notification.recipients.";
gs.info("Business rule 'RF Service Request En Route for Service' running");
if(current.getDisplayValue("u_site").toLowerCase().contains("xxxxx")) {
gs.info("Raising event using xxxxx recipients");
recipients = gs.getProperty(property_root + "xxxxx") || "";
gs.eventQueue(event, current, recipients);
} else if (current.getDisplayValue("u_site").toLowerCase().contains("twiggs")) {
//etc
} else {
gs.warn("Site not recognized! No notification will be sent.");
}
gs.info("Business rule complete");
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 09:51 AM
Hi
There could be numerous reasons why the notification isn't sent. We don't know what you've researched before this (hopefully, you've done some). There are numerous posts on the forums about this same situation and I've personally have responded with 8-10 bullet points of things to check.
Feel free to search the forums as there's great information out there.
Luckily, someone has already asked about you to clarify if the event itself even shows in your logs (you should have checked that first and foremost after seeing the info in your logs).
From there, if send to event creator, parm1 contains recipients is checked, no advanced condition on the notification (or ensuring it returns true if so), the notification is active, mail script, if used, isn't broken, which causes problems, the recipient is active and has a valid email primary channel setup in their preferences AND notifications turn on....and you don't have a before business rule on the sys_email table that may be aborting this....it should send.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 03:47 PM
Can you do a gs.info of your recipients variable? Alternatively, can you specify a specific recipient in the notification to send to (instead of Parm1)?
Often when I have notifications that do not send, it is because I was passing an empty variable for the recipients or was passing the event creator in (in cases like yours where I am the Event Creator and I am not wanting to email the Event Creator).
When troubleshooting, I'll often try to send just the email itself with everything hardcoded. Then if it does not send, I will look to the logs as to why. So I'll hard code a user for the notification, then just manually trigger through a background script (the Scripts - Background menu option, I think VS Code has a similar feature too if you use that). The logs should spit out an error if something is wrong at that point.
I am assuming your notification has the Active flag set to true. It's not in your screenshot so I cannot tell, but it's a simple mistake we all make sometimes. I just didn't want to lead with that as it might seem rude, like when the help desk asks you to turn your computer off and on as their first question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 06:34 AM
The recipients is my email address. The Notification is active. Sending email is enabled.
If I check Send to Event Creator it sends email as expected.
It does not send email if I just select my name under Users. (I checked my email address - it's correct). I've been triggering it through a script, and through the UI, and not observed any difference in behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 02:11 PM
I think you may have discovered the problem, Send to event creator was turned off. What this checkbox controls is whether the person who generated the event is able to receive an email.
A good example of this in action is within Incident. When you assign an Incident to yourself, you would generate an event for an email to go out to the Assigned To person letting them know of an Incident assigned to them. However, you would likely not want this email to go out if you assign the Incident to yourself. That makes sense, you know you assigned it to yourself and an email confirming it is likely useless.
So in your testing, is the recipient value you pass in your own email address? If so, then it will not work unless you have the checkmark in the box for Send to event creator.
You can test this out by passing in an email address (a different email address than yourself) here:
gs.eventQueue(event, current, "email address other than you");
Because you are able to get it working with a user on the notification, it looks like the recipients value you pass in is the problem. Simplify your testing, pass in a recipient value with a different email address.
Once you have this working, you can troubleshoot your recipients value. But it feels like the Send to event creator might be a problem here because it was not checked off.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 08:59 PM
Hi you dont have any value in receipents, there should be some email id over there since your sending it to parm1. Hence the email is not going out. Also check send event creator checkbox true
Harish