What's the \${CMS_URI} variant for Service Portals?

peterraeves
Mega Guru

We have created a notification with a link, which should point to an HR Case on the service portal /sp. I am aware of ${URI} and ${CMS_URI} for the /ess. But what is the equivalent for the Service Portal?

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



There is no equivalent for the service portal, as the path depends on they way your portal is set up (the name of the page which shows the specific record type).


But its easy to create your own mail script and refer to it in the notification.



We have a mail script called "URI_REF_SP". It looks like this



//Adds an URI_REF pointing the the Service Portal


//URL depending on current table - if an approval we will point to the approving record


//incident -> /sp?id=ticket&table=incident&sys_id=[sys_id]


//sc_req_item -> /sp?id=sc_req_item&sys_id=[sys_id]


//sc_request -> /sp?id=sc_request&sys_id=[sys_id]


//other tables point at form view -> sp?id=form&table=[table]&sys_id=[sys_id]



(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


/* Optional GlideRecord */ event) {


var table = current.getTableName();


var url = '';


var sys_id = current.sys_id;


var number = current.number;


//If running on approval, the link must point the task being approved


if (table == 'sysapproval_approver') {


          table = current.sysapproval.sys_class_name;


          sys_id = current.sysapproval;


          number = current.sysapproval.number;


}


if (table == 'incident')


          url = "/sp?id=ticket&table=incident&sys_id=" + sys_id;


else if (table == 'sc_req_item')


          url = "/sp?id=sc_req_item&sys_id=" + sys_id;


else if (table == 'sc_request')


          url = "/sp?id=sc_request&sys_id=" + sys_id;


else


          url = "/sp?id=form&table=" + table + "&sys_id=" + sys_id;



template.print("<a href='" + url + "'>" + number + "</a>");



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



You call it from the notification using ${mail_script: URI_REF_SP}


View solution in original post

3 REPLIES 3

larstange
Mega Sage

Hi



There is no equivalent for the service portal, as the path depends on they way your portal is set up (the name of the page which shows the specific record type).


But its easy to create your own mail script and refer to it in the notification.



We have a mail script called "URI_REF_SP". It looks like this



//Adds an URI_REF pointing the the Service Portal


//URL depending on current table - if an approval we will point to the approving record


//incident -> /sp?id=ticket&table=incident&sys_id=[sys_id]


//sc_req_item -> /sp?id=sc_req_item&sys_id=[sys_id]


//sc_request -> /sp?id=sc_request&sys_id=[sys_id]


//other tables point at form view -> sp?id=form&table=[table]&sys_id=[sys_id]



(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


/* Optional GlideRecord */ event) {


var table = current.getTableName();


var url = '';


var sys_id = current.sys_id;


var number = current.number;


//If running on approval, the link must point the task being approved


if (table == 'sysapproval_approver') {


          table = current.sysapproval.sys_class_name;


          sys_id = current.sysapproval;


          number = current.sysapproval.number;


}


if (table == 'incident')


          url = "/sp?id=ticket&table=incident&sys_id=" + sys_id;


else if (table == 'sc_req_item')


          url = "/sp?id=sc_req_item&sys_id=" + sys_id;


else if (table == 'sc_request')


          url = "/sp?id=sc_request&sys_id=" + sys_id;


else


          url = "/sp?id=form&table=" + table + "&sys_id=" + sys_id;



template.print("<a href='" + url + "'>" + number + "</a>");



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



You call it from the notification using ${mail_script: URI_REF_SP}


manishm
Mega Guru

This is great help, thank you. Just a couple of quick corrections

1) The request and requested item URLs should be:

url = "/sp?id=sc_req_item&table=sc_req_item&&sys_id=" + sys_id;

url = "/sp?id=sc_request&table=sc_request&sys_id=" + sys_id;

2) The extra space between the mail_script and URI_REF_SP gave me a bit of trouble. Posting to help others who may run into the same issue. 

{mail_script:URI_REF_SP}

thomast63
Mega Contributor

So this works great, but I noticed that when an req_item is rejected the email send out links to sc_req_item&sysid and the page that comes up is the breakout page, 

Do I just need to add a new page for this?