Single notification with multiple mail content help

Community Alums
Not applicable

Hiii,

I have requirement to create one notification and trigger multiple content mails based on some conditions.

ex: once request created there is a mail going with request has been created. so in same notification i want to change the content only for one catalog item, means for abc item, different content mail should trigger.

how can we achieve this.

Regards,

Roopa

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

you can trigger the notification based on condition as well you can add the condition in email script . 

adding sample Email script here. 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
	if(current.state==1){
		email.setSubject('Hi Good Morning !!');
		template.print('Welcome To Servicenow' + "<br/> State: " + current.state.getDisplayValue());



	}
	else{
		email.setSubject('Hi Good Night !!');
		template.print('Welcome To Servicenow Community' + "<br/> State: " + current.state.getDisplayValue());
	}
	

})(current, template, email, email_action, event);

 

Note: here what i did, if my RITM state is open then notification will trigger with good morning subject else it will set the email subject good night. you can make some modification in email script based on your need. 

 

 

View solution in original post

9 REPLIES 9

Hello,

     If you want to set the different content for one catalog item, I would suggest to take Allen's solution. But if you want to implement the dynamic content for multiple catalog items, then email notification scripts might be useful.

Please look into the below link for creating an email script

https://docs.servicenow.com/bundle/london-servicenow-platform/page/script/server-scripting/concept/c...

 

Regards,

Jagadeesh

 

Community Alums
Not applicable

i gone through this link, but not getting from where i have to start and how to start.

 

Allen Andreas
Administrator
Administrator

The easier way (not saying it's the better way, but it's not that complicated)...is the create a second notification with the contents you want to send for that one catalog item. In the conditions section for the original notification that goes out for most all, you'd just set it to be IS NOT item name like:

find_real_file.png

And then your new notification, you'd set the condition to be IS blah blah.

This is just a quick way to achieve what you want, but isn't ideal for scaling as it can get messy if you have more and more items with specific notifications.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Community Alums
Not applicable

Hi Allen,

yes this is easy way creating one more notification with condition as item name 

 

But i want to achieve it through email scripts, like one Notification with different content based on item name.

 

Harsh Vardhan
Giga Patron

you can trigger the notification based on condition as well you can add the condition in email script . 

adding sample Email script here. 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
	if(current.state==1){
		email.setSubject('Hi Good Morning !!');
		template.print('Welcome To Servicenow' + "<br/> State: " + current.state.getDisplayValue());



	}
	else{
		email.setSubject('Hi Good Night !!');
		template.print('Welcome To Servicenow Community' + "<br/> State: " + current.state.getDisplayValue());
	}
	

})(current, template, email, email_action, event);

 

Note: here what i did, if my RITM state is open then notification will trigger with good morning subject else it will set the email subject good night. you can make some modification in email script based on your need.