- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2016 05:54 PM
Hi all,
We would like to have emails going to the end users contain the portal link to their request / incident. I am using email notifications.
The actual link that we have is the following:
Incident:
http://<instance>.service-now.com/sp?id=ticket&table=incident&sys_id=22b899754f112240f5333d501310c786
Request:
http://<instance>.service-now.com/sp?id=sc_request&table=sc_request&sys_id=9350c9f14fddee00f5333d501310c715
I have been doing some research, and found a lot pointing towards this wiki entry: Scripting for Email Notifications - ServiceNow Wiki
That entry has helped my understanding, however it is old and is referring to the ESS page.
With the code that it suggests, it seems to always add incident.do?sysparm_document_key=incident in the code.
For example:
${CMS_URI+sp?id=ticket&table=incident}
https://<instance>.service-now.com/sp?id=ticket&table=incident.do?sysparm_document_key=incident,619dac624f09ea00f5333d501310c769
I know that I am missing something, hopefully someone out there can easily identify it.
Thanks in Advance!
Brendan
Solved! Go to Solution.
- 20,008 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 04:27 PM
In our own instance I included Service Portal links by using an email notification script, the contents of which looks like:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">Link</a>';
template.print(url);
})(current, template, email, email_action, event);
I can then reference this in email notifications/templates by: ${mail_script:service_portal_link}
Note: The syntax highlighting looks a little off in the code snippet above, but you get the idea. I also replaced the name of our portal with "sp" to remain consistent with your example above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 06:22 PM
Hi dylanhasselquist,
This is amazing!!! Thank you for this.
I know im late to this post, but is there a way to change the standard text from being "Link" on the email?
Thanks
Ed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 07:36 PM
Hi Ed,
It sure is amazing. So good to see that 13 people found Dylan's solution helpful.
to your question, In the mail script, you need to edit the bold part below. As you can see, I use ${number}, which will change the text to the corresponding Incident number.
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">${number}</a>';
Let me know if that helps
Cheers,
Brendan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2017 07:12 AM
This has all been very helpful! I'm stuck on one thing. Our script is pulling RITM's from the REQ. I want to display the RITM number as the link, but the above example is returning the REQ number. Any ideas? Here is what I have.
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
var stage = gr.stage.getDisplayValue();
if (JSUtil.nil(stage))
stage = gr.stage.getChoiceValue();
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=sc_request&table=sc_req_item&sys_id=' + gr.sys_id + '">${number}</a>';
template.print(url + ": " + gr.cat_item.getDisplayValue() + ", Stage: " + stage + ", Price: " + gr.cat_item.price + "<br />");
}
Thanks!!
-Skip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2017 03:30 PM
Skip,
Instead of ${number}, you would want to add the number from the glide record. Something like:
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=sc_request&table=sc_req_item&sys_id=' + gr.sys_id + '">' + gr.number + '</a>';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2017 07:02 AM
That was it! I was close...tried gr.number, but didn't have the right syntax.
Thank you!!!