
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 07:27 AM
I am sending an email notification to a single user about an incident being assigned to their group. In the email notification, I am looking to include a link that will allow the user to click on it and have the specified incident assigned to them.
I have read that I might be able to use Processors for this requirement, but I am not at all familiar with creating/using processors. Any help is much appreciated!
Thanks,
Chris
Regards,
Chris Perry
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2018 10:54 AM
I got this to work on my PDI
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_unwrapped_url" jelly="true">
var currentUser = gs.getUserID();
var incidentFromURL = RP.getParameterValue('incident');
var link = '';
var incident = new GlideRecord('incident');
if(incident.get('number', incidentFromURL)) {
incident.setValue('assigned_to', currentUser);
incident.update();
gs.addInfoMessage(incident.getDisplayValue() + ' has been updated.');
//gs.sendRedirect(incident.getLink());
link = incident.getLink();
}
link || 'incident.do?sysparm_query=number=' + incidentFromURL;
</g2:evaluate>
${gs.getMessage("Redirecting to your the incident")}...
</j:jelly>
Client Script
document.location.href = "$[JS:jvar_unwrapped_url]";
Link to the page with a url like /i.do?incident=INC12345

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2018 06:16 AM
Thank you so much, Jace! This is super close, the only issue I am running into now is getting the UI page to automatically redirect to the incident record. The assign to logged in user piece is working perfectly, but the redirect isn't working.
I have tried:
- gs.redirect(link)
- gs.setRedirect(link)
- response.sendRedirect(link)
But none of the above are working, it just stays on the UI page's URL w/ a blank page, any ideas?
Regards,
Chris Perry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2018 06:37 AM
Maybe we are overthinking this.
Maybe we ought to set the redirect in the html after the g:eval
<script>
var params = new URLSearchParams(location.search.slice(1));
params.get('id')
var url = '/incident.do?sysparm_query=number=' + params.get('incident');
window.location = url;
</script>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2018 06:56 AM
Getting closer still... the redirect is now happening, but it seems that 'params.get('incident');' is returning null in the url, which brings me to this URL w/ info message of 'Record not found': https://ceidev.service-now.com/nav_to.do?uri=%2Fincident.do%3Fsysparm_query%3Dnumber%3Dnull
Here is the script I am now using based on your last response:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var currentUser = gs.getUserID();
//var incidentFromURL = RP.getParameterValue('incident');
var incidentFromURL = 'INC0228551';
var link = '';
//expects url of /uipage.do?incident=INC12345
var incident = new GlideRecord('incident');
if(incident.get('number', incidentFromURL)) {
incident.setValue('assigned_to', currentUser);
incident.update();
//link = 'incident.do?sys_id=' + incident.sys_id;
}
//gs.addInfoMessage('link is: ' + link);
//gs.redirect(link);
</g:evaluate>
<script>
var params = new URLSearchParams(location.search.slice(1));
params.get('id');
var url = '/incident.do?sysparm_query=number=' + params.get('incident');
window.location = url;
</script>
</j:jelly>
Regards,
Chris Perry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2018 10:54 AM
I got this to work on my PDI
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_unwrapped_url" jelly="true">
var currentUser = gs.getUserID();
var incidentFromURL = RP.getParameterValue('incident');
var link = '';
var incident = new GlideRecord('incident');
if(incident.get('number', incidentFromURL)) {
incident.setValue('assigned_to', currentUser);
incident.update();
gs.addInfoMessage(incident.getDisplayValue() + ' has been updated.');
//gs.sendRedirect(incident.getLink());
link = incident.getLink();
}
link || 'incident.do?sysparm_query=number=' + incidentFromURL;
</g2:evaluate>
${gs.getMessage("Redirecting to your the incident")}...
</j:jelly>
Client Script
document.location.href = "$[JS:jvar_unwrapped_url]";
Link to the page with a url like /i.do?incident=INC12345

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2018 06:37 AM
Thanks so much, Jace! Worked like a charm - I really appreciate your help!!!
-Chris
Regards,
Chris Perry