Email script is not working

AnilM99
Tera Expert

Hello team,

The below script is not working 

 

 
The same script I wrote a year back for one catalog item was working fine, but now it is not working for other items.
 
Thanks 
Anil!
5 REPLIES 5

SumanthDosapati
Mega Sage
Mega Sage

@AnilM99 

Question is not clear.

Broken link.

 

Sai62
Tera Contributor

Hi Anil

 

Are you trying to build an URL on a notification to navigate to any RITM record by using email script? Please confirm

 

Thanks

Sai Vijitha

AnilM99
Tera Expert

Hi everyone, thanks for the response.

My requirement is 

 

I build a new catalog item—"Request a Device." 

variable

ritm_number

device name

 

The onboarding workflow sends a notification to the manager with the link.

If the manager clicks the link via email, it redirects to the portal, and the variable ritm_number will auto-populate with the onboarding ritm number.

 

Email script.

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
    
var urls =
/sp?id=sc_cat_item&sys_id=73b1bafa9752cd1021983d1e6253afb5&sysparm_variables={"ritm_number":"'+current.sys_id+'"};
   
template.print('<a title="Please click here to submit new device request." href='+urls+'>Please click here to submit new device request.⁣/a>');
  
})(current, template, email, email_action, event);
 
Thanks 
Anil

 

 

 

Nilesh Pol
Tera Guru

Hi @AnilM99 fix your email as below:

 

(function runMailScript(current, template, email, email_action, event) {

var sysId = '73b1bafa9752cd1021983d1e6253afb5'; // Catalog item sys_id
var ritmNumber = current.sys_id; // The current RITM sys_id

var baseUrl = gs.getProperty('glide.servlet.uri'); // Gets your instance base URL

var link = baseUrl + 'sp?id=sc_cat_item&sys_id=' + sysId +
'&sysparm_variables=' + encodeURIComponent(JSON.stringify({ritm_number: ritmNumber}));

template.print('<a title="Please click here to submit new device request." href="' + link + '">Please click here to submit new device request.</a>');

})(current, template, email, email_action, event);