email script returns undefined

sonita
Giga Guru

in the email notification , we have an email script that returns undefined , any ideas please?

 

template.print("vendor:  "+ current.variables.vendor_name + "  submitted by : "+current.variables.requestor.getDisplayValue() +"  was added to the vendor list .");

 

find_real_file.png

and this is the notifications:

 

find_real_file.png

 

1 ACCEPTED SOLUTION

Hi Sonita,

I'm not entirely sure what changed between your upgrade but you should be able to get the variables through the GlideRecord. Try the following in your email script:

var ritm = new GlideRecord("sc_req_item");

	//I assume the email notification is being run on the sc_req_item table
	if (ritm.get(current.sys_id)) {
		template.print(gs.getMessage("vendor: {0} submitted by : {1} was added to the vendor list .",[ritm.variables.vendor_name,ritm.variables.requestor.getDisplayValue()]));
	}

I haven't been able to test this but let me know if it worked for you.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

View solution in original post

4 REPLIES 4

Raghu Loganatha
Kilo Guru

Sonita, 

Can you check the variable names and complete code where you are querying the record information? Try to debug your code using background script. 

 

~Raghu.

Brent Sutton
Mega Sage

Hi Sonita,

Can you please advise which table the notification is being generated from i.e. sc_request or sc_req_item.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

actually it happened after upgrade; it was working fine in previous release

Hi Sonita,

I'm not entirely sure what changed between your upgrade but you should be able to get the variables through the GlideRecord. Try the following in your email script:

var ritm = new GlideRecord("sc_req_item");

	//I assume the email notification is being run on the sc_req_item table
	if (ritm.get(current.sys_id)) {
		template.print(gs.getMessage("vendor: {0} submitted by : {1} was added to the vendor list .",[ritm.variables.vendor_name,ritm.variables.requestor.getDisplayValue()]));
	}

I haven't been able to test this but let me know if it worked for you.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.