- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:53 AM
How to send a notification to created by instead of assigned to not provided. Can anyone help me on the email script?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 02:15 AM
hello
we cannot set TO address from email script there are no OOB methods i guess.
we can only set CC and BCC.
One work around is we can use event mechanism to set the TO address
you can create a event in event registry table and write a script like below in a BR on release table with your conditions and it can be an after insert BR
if(current.assigned_to=="")
{
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',current.sys_created_by);
gr.query();
if(gr.next())
{
gs.eventQueue('your_event_name',current,gr.sys_id,'');
}
}
else
{
gs.eventQueue('your_event_name',current,current.assigned_to,'');
}
And in your notification change the trigger condition to event and give your event name so that when this event fires it sends the notification.
Also you need to check Recipient contains parm1 check box in the who will receive tab
hope this helps
please mark my answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:59 AM
Hi,
your email is on which table?
If it has opened_by field then use that.
If not then you will have to use event queue approach and trigger email via After insert BR on that table
Notification: Link with Event, Event parm1 contains Recipient - True
BR Script:
gs.eventQueue('event_name', current, gs.getUserID());
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
‎09-01-2022 01:52 AM
Hi,
Actually my table is Release[rm_release]. The notification send to assigned to , if assigned to not provided then only send to created by. how to write the email script for that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 04:15 AM
Hi
As I already said you cannot include created by in email directly.
You will have to use gs.eventQueue() approach which I already shared as 1st response to your question.
Did you mistakenly marked other response as correct?
You just had to enhance the script I shared
if(current.assigned_to)
gs.eventQueue('event_name', current, current.assigned_to);
else
gs.eventQueue('event_name', current, gs.getUserID());
Would you mind marking appropriate response as correct based on timely response?
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
‎09-01-2022 01:15 AM
In the email script below
var gr=new GlideRecord('sys_user');
gr.get('user_id',current.sys_created_by);
email.addAddress("to",gr.email,gr.name);