How to Send a notification to created by using email script

PRAGHATIESH S
Tera Expert

How to send a notification to created by instead of assigned to not provided. Can anyone help me on the email script?

1 ACCEPTED SOLUTION

hello @PRAGHATIESH S ,

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

View solution in original post

7 REPLIES 7

Vasantharajan N
Giga Sage
Giga Sage

You can achieve this without email script because Created By field is an OOTB field which you will see in in every table in the platform. So use Users/Groups in fields in your email notification configuration and select the field Created by

Please refer to the screenshot below

find_real_file.png


Thanks & Regards,
Vasanth

Hi,

    Actually my table is Release[rm_release]. The notification send to assigned to , if assigned to is not provided  then only send to created by. how to write the email script for that?

hello @PRAGHATIESH S ,

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