- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:59 PM
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"
Please can someone help me understand what I am missing please
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 05:15 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 03:44 PM
Thanks @Rutuja K,
FYI, use "<br>" instead of "\n" for new line.
Can you try printing out the array[i] in your log?
Also, try creating a single variable that concatenates the link and take out the template.print outside of the loop.
e.g.
var catalogLinks = "";
for (var i = 0; i < array.length; i++) {
var link = "&sys_id=" + array[i];
var url = "<a target='_blank' href = " + link + ">Catalog Item </a><br>";
catalogLinks += url;
}
template.print(catalogLinks);
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 03:35 PM
Hi, if you are querying for multiple sys_id's, try sys_idIN' + array[i];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 05:15 PM
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);