Adding cat item variables to email notification

matthew_magee1
Giga Guru

Hi all,

I think I'm trying to do something pretty simple.

 

I have a few variables on my catalog item form that I need to pull into an email notification. One of the fields being 'alt_poc_phone'

 

I've tried GlideRecord and current.variable_pool.alt_poc_phone and neither seems to work.

 

I've also referenced the following wiki page (Scripting for Email Notifications - ServiceNow Wiki), but something's not clicking (on my part).

 

Any help is greatly appreciated (with examples)

 

MM

1 ACCEPTED SOLUTION

Mandar/Adam-



Follow up to my post. For some reason the mail script is working now. I'm not sure why it wasnt' working earlier. I guess I had a typo or something.



Here's the script that works:



<mail_script>


var item = new GlideRecord("sc_req_item");


item.addQuery("request", current.sys_id);


item.query();


while(item.next()) {


var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();


var misc = item.variable_pool.alt_poc;


template.print(catalogItem + "<br/> Field: " + misc);


}


</mail_script>



Really appreciate the feedback guys, couldn't have done this without you-



On to my next challenge


View solution in original post

41 REPLIES 41

Hi Your script for sending Variables through Notification is working good. But here it is displaying the value of the filed , is that possible to display the text in the field ?



example : If the approver name needs to be displayed from reference field it is displaying sysID instead of Approver name.


Hi Sai, this happens because its a reference field which stores the sys_id of the field value of the table which its referencing. So you would have to use the function - getDisplayValue() to get the approver name.



Let me know how you go


Even getDisplayValue() is displaying the sysid , Is there any other way ?


Try .getRefRecord().getDisplayValue()


.getRefRecord().getDisplayValue() --- This is also not displaying the text value