The CreatorCon Call for Content is officially open! Get started here.

Catalog item link using Email script in Notification

Rutuja K
Giga Guru

Hi All,

 

I have created email script which should return link to all catalog items one particular service owner owns. Below is email script I created. In this case, there are 3 catalog item Test user owns, I checked logs and url is returning 3 different links BUT in notification only first one is coming correctly and for other 2, sys_id is blank.


 
 

and Catalog item is are not coming in line even after using "\n"

RutujaK_5-1707947941851.png

 

 

RutujaK_3-1707947873170.png

 

 

Please can someone help me understand what I am missing please

Thank you!

 

1 ACCEPTED SOLUTION

Rutuja K
Giga Guru

Below is Email Script: 


// Add your code here
var cNames = event. parm2. tostring();

var cat item link = ''
var cat_item = new GLideRecord ("sc_cat_item") ;
cat_item. addEncodedQuery ('sys_idIN'+ cNames) ;
cat_item. query ();
while(cat_item.next()){
template print ("<a href='https://"+gs.getProperty ('instance_name')+". service-now.com/portal?id=sc_cat_iten&sys_id= "+cat_item.sys_id.toString()+" ' target='_blank' > " + cat_item.name.toString() + " </a><br>");
}) (current, template,
email, email action, event);

View solution in original post

7 REPLIES 7

James Chun
Kilo Patron

Hi @Rutuja K ,

 

When setting the 'link' variable, did you put 'instance URL' as a string on purpose?

If not, try replacing line 15 with

 

var link = gs.getProperty('glide.servlet.uri') + "/portal&sys_id=" + array[i];

 

 

Thanks

Hi James, 

 

Thanks for response.

I used getProperty API, Too post code on community, I changed it to "Instance URL"

Hi @Rutuja K,

 

Can you try removing "\n" in line 18?

 

Thanks

Hi James,

 

I tried removing \n, but still getting blank sys_id in emails.