Email Script to link the record to backend

Sathiskumar_D
Giga Sage

Hello ,

 

I have a mail script for customer service(sn_customerservice_case). I want to include a link to the record "backend" whenever a customer is attaching a document on the service portal ticket.

i have lots of questions on ${URI} and ${URI_REF} with LINK word to it.I am not sure how to implement it.My code is very generic and i am not sure how to modify this to get the correct record in the backend.Please help me in fixing this error.

 

var gr = new GlideRecord("sys_attachment");
    gr.addQuery('table_name', 'sn_customerservice_case');
    gr.query();
    while (gr.next()) {
       
        template.print('Attachment: <a href="https//' + gs.getProperty("glide.servlet.uri") + '/sys_attachment.do?sys_id=' + gr.sys_id + '">' + gr.file_name + '</a>');
    }
1 ACCEPTED SOLUTION

Hi, it would have been helpful if you had earlier provided clear details regarding any customization that was preventing OOB functionality from working .
What exactly does 'they have hard-coded servicenow instance' mean?

 

Creating a URL for direct access to an instance record via mail script would look something like

var instanceURL = gs.getProperty('glide.servlet.uri');
var myTable = current.sys_class_name;
    
var myURL = '<a href=' + instanceURL + '/nav_to.do?uri=' + myTable + '.do?sys_id=' + current.sys_id + '>' + current.number'</a>';

template.print(myURL);

 

if you are unsure of URL format on any form record header,
you can right click and select 'Copy URL' from the menu.

 

 

View solution in original post

7 REPLIES 7

Hi, it would have been helpful if you had earlier provided clear details regarding any customization that was preventing OOB functionality from working .
What exactly does 'they have hard-coded servicenow instance' mean?

 

Creating a URL for direct access to an instance record via mail script would look something like

var instanceURL = gs.getProperty('glide.servlet.uri');
var myTable = current.sys_class_name;
    
var myURL = '<a href=' + instanceURL + '/nav_to.do?uri=' + myTable + '.do?sys_id=' + current.sys_id + '>' + current.number'</a>';

template.print(myURL);

 

if you are unsure of URL format on any form record header,
you can right click and select 'Copy URL' from the menu.

 

 

${URI} and ${URI_REF} provide the link and Case#. However, when a user clicks , it is directing them to different page which is not accessible at all. When i asked my architect, told me that they "hardcoded this and have to be corrected in a different environment". I asked further details but I didn't get any response. Thanks for your reply. I will move on from the mail script.  

Sathiskumar_D
Giga Sage

Approvers need to see the attachment in the case record whenever the attachment is added.