- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2018 01:39 PM
We have some users who interact with SerivceNow via a separate web portal. Management from the other portal has requested that the notifications for companies that use the other web portal use a URL for that portal. So we have a check box on the companies that use the other web portal.
The ask is that for notifications if the "u_in_portal" is true the URL look something like https://portal.com/ticket_type/[sys_id]
the if "u_in_portal" is false use the regular ServiceNow URL to the record
Is there a way to dynamically add the URL to the email notification based on the "u_in_portal" filed on the company page?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2018 06:47 AM
Final solution
var num = current.sys_id; //quick easy grab of current record sys_id to use in building URL
var gr = new GlideRecord('change_request'); //New glideRecord on change_request table
gr.addQuery("sys_id", num); //Limits the record look up to just the current record sys_id
gr.query(); //executes the query
while (gr.next()); //while there is a next record (esentially for each record found) do the following
//If the check box is true (checked)
if (gr.u_checkbox == true){
//Start of string sentence to show in the email body
template.print("More details can be found ");
//create variable to incld the part of the URL that will remain constant + the current sys_id variable from above (num)
var pLink = "https://company.com/subsite/support/#/editChangeRequest/" + current.sys_id;
//create html anchor (<a href) to create the actual URL link using the word here as the text link
var pAnchor = "<a href='" + pLink +"'>" + "here." + "</a>";
template.print(pAnchor + "<br />");
}
//If the \check box ix false (not checked) then the URL link will be created the same way as above, but will link back to the record in ServiceNow
if (gr.u_checkbox == false){
template.print("More details can be found ");
var sLink = "https://instance.service-now.com/nav_to.do?uri=change_request.do?sys_id=" + current.sys_id;
var sAnchor = "<a href='" + sLink +"'>" + "here." + "</a>";
template.print(sAnchor + "<br />");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2018 06:47 AM
Final solution
var num = current.sys_id; //quick easy grab of current record sys_id to use in building URL
var gr = new GlideRecord('change_request'); //New glideRecord on change_request table
gr.addQuery("sys_id", num); //Limits the record look up to just the current record sys_id
gr.query(); //executes the query
while (gr.next()); //while there is a next record (esentially for each record found) do the following
//If the check box is true (checked)
if (gr.u_checkbox == true){
//Start of string sentence to show in the email body
template.print("More details can be found ");
//create variable to incld the part of the URL that will remain constant + the current sys_id variable from above (num)
var pLink = "https://company.com/subsite/support/#/editChangeRequest/" + current.sys_id;
//create html anchor (<a href) to create the actual URL link using the word here as the text link
var pAnchor = "<a href='" + pLink +"'>" + "here." + "</a>";
template.print(pAnchor + "<br />");
}
//If the \check box ix false (not checked) then the URL link will be created the same way as above, but will link back to the record in ServiceNow
if (gr.u_checkbox == false){
template.print("More details can be found ");
var sLink = "https://instance.service-now.com/nav_to.do?uri=change_request.do?sys_id=" + current.sys_id;
var sAnchor = "<a href='" + sLink +"'>" + "here." + "</a>";
template.print(sAnchor + "<br />");
}