Email notification based on record producer variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 03:52 AM
Hi All,
I currently have various record producers set up, when completed, an email notification is sent to specific emails with the input of all variables within the record producer.
This is set up via an event, a business rule and a notification all within a custom application - this is working great!
However, I am trying to configure another notification based on the input of one of the variables within the record producer i.e -
If variable 'Team Leader' is 'Joe Bloggs' then send this email notification to 'Joe Bloggs'.
Everything I have tried so far is not sending one.
Does anyone have any ideas on how to achieve this?
Thank you,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 03:58 AM
Hi,
you will have to trigger it via event and after update BR on your table
Try this in the after update BR
I assume team leader variable is reference to sys_user table
BR: After update on your Record producer target table
current.variables.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.variables.teamLeader.name == 'Joe Bloggs'){
gs.eventQueue('event_name', current, current.variables.teamLeader.email, '');
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 04:07 AM
Thanks for marking my response as helpful.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 04:29 AM
Hi Ankur,
This is what the current business rule looks like -
(function executeRule(current, previous /*null when async*/) {
var email;
var grFormConfig = new GlideRecord("x_polo_forms_configuration");
grFormConfig.addQuery("form", current.form);
grFormConfig.query();
while (grFormConfig.next()){
email = grFormConfig.email;
gs.eventQueue("x_polo_forms.form_request_created", current, email, "");
}
})(current, previous);
Do I add your code to this or create a new business rule?
Also, the Team Leader Variable is a select box with different names. I had issues when making this a reference variable.
I was going to go down the route of creating a separate email notification for each name on the list due to the above.
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 04:34 AM
Hi,
please use separate business rule on that table as it would be easier to debug in later stages
is this your target table of record producer -> x_polo_forms_configuration
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader