Email notification based on record producer variable?

Community Alums
Not applicable

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

 

 

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Alex 

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Community Alums
Not applicable

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

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader