Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Email script for the updated user not appearing in the notification when the user updates the ticket

phr
Tera Contributor

Hi All,

 

I have a requirement where i need to send the notification to the users who update the incident. We have a email script which is already defined and is fetching the email instead of the name .

reference image :

phr_0-1722522395265.png

 

phr_1-1722522469042.png

 

I did write the email script to fetch the name instead of the email :

phr_2-1722522520794.png

 

But this isn't fetching the name 

phr_3-1722522551574.png

 

phr_4-1722522599155.png

 

How to achieve this?

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @phr 

Please change your email script to the one like below.

 

var usrGr = new GlideRecord("sys_user");
usrGr.addEncodedQuery("user_nameSTARTSWITH" + current.sys_updated_by);
usrGr.query();
if(usrGr._next()){
	template.print(usrGr.getValue('name'));
}

 

Please mark my answer helpful 👍 and accept as a solution ✔️ if it helped.

 

Thanks,
Anvesh

View solution in original post

6 REPLIES 6

LorenzVdV
Giga Guru

You don't have 2 mail scripts with that name?

Add a gs.log(); on line 2 and 8 of your mail script.

phr
Tera Contributor

Hi @LorenzVdV ,

 

One was "updatedby" and the other was the custom client script "getUpdatedBy" which wasn't working fine.

I modified the code now and is working fine.

 

Thank you,