- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 08:49 AM
I have the following mail script for Change Approval Reminders:
//First, we need to locate our current user's approvals (the parm1 variable contains the current approver)
var app = new GlideRecord('sysapproval_approver'); //create a query to retrieve open approvals
app.addQuery('state','requested'); //only retrieve approvals that are pending
app.addQuery('approver',event.parm1); //only find approvals for the current approver
app.addQuery('sysapproval.sys_class_name','change_request'); //only find approvals for change reqeusts
app.query();
while(app.next()){
//now that we have an approval for that user, we are going to look up the change tickets they need to approve and print out the data
var chg = new GlideRecord('change_request'); //find the first related Change approval and print info
chg.get(app.sysapproval);
template.print('<p>You have an open change approval for ' + chg.number + '</br>');
template.print('<b>Description:</b> ' + chg.short_description + '</br>');
template.print('<b>Scheduled date:</b> ' + chg.work_start + '</p>');
}
I would like to make the chg.number a clickable link. I am unable to do so with ${URI_REF}. I would rather not have a separate link that says click here and instead have the CHG number itself clickable (Screenshot below). Any help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 10:01 AM
//I do want the link to point to the Approval and note the Change itself //
I just noticed this. So the link needs to be...
template.print('<p>You have an open change approval for <A href="https://yourinstance.service-now.com/nav_to.do?uri=sysapproval_approver.do?sys_id=' + app.sys_id + '">' + chg.number + '</a><BR>');
One little detail...I think chg.work_start should be chg.work_start.getDisplayValue() so that it accounts for user time zone. Not sure if this is relevant to you, if you have people in different time zones.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 09:12 AM
Paul, thanks this was great as the link is now being generated. I do want the link to point to the Approval and note the Change itself however now it prints the same Change Number for each link. My original notification email looked like this:
I have modified the script to:
//First, we need to locate our current user's approvals (the parm1 variable contains the current approver)
var app = new GlideRecord('sysapproval_approver'); //create a query to retrieve open approvals
app.addQuery('state','requested'); //only retrieve approvals that are pending
app.addQuery('approver',event.parm1); //only find approvals for the current approver
app.addQuery('sysapproval.sys_class_name','change_request'); //only find approvals for change reqeusts
app.query();
while(app.next()){
//now that we have an approval for that user, we are going to look up the change tickets they need to approve and print out the data
var chg = new GlideRecord('change_request'); //find the first related Change approval and print info
chg.get(app.sysapproval);
template.print('<p>You have an open change approval for ' + '${URI_REF}' + '</br>');
template.print('<b>Description:</b> ' + chg.short_description + '</br>');
template.print('<b>Scheduled date:</b> ' + chg.work_start + '</p>');
}
Now my notification e-mail looks like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 09:57 AM
It makes sense that it's doing that, because the URI_REF is being generated from the record that triggered the notification. You'll have to go the other route and manually build the URL...
template.print('<p>You have an open change approval for <A href="https://yourinstance.service-now.com/nav_to.do?uri=change_request.do?sys_id=' + app.sysapproval.sys_id + '">' + app.sysapproval.number + '</a><BR>');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 10:01 AM
//I do want the link to point to the Approval and note the Change itself //
I just noticed this. So the link needs to be...
template.print('<p>You have an open change approval for <A href="https://yourinstance.service-now.com/nav_to.do?uri=sysapproval_approver.do?sys_id=' + app.sys_id + '">' + chg.number + '</a><BR>');
One little detail...I think chg.work_start should be chg.work_start.getDisplayValue() so that it accounts for user time zone. Not sure if this is relevant to you, if you have people in different time zones.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 10:39 AM
Thank you very much Paul. This worked and we do have users in California so I will account for that in the chg.work_start. Great catch and thanks again for your help with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 10:41 AM
You're welcome. I had never considered the idea of showing the CHG# but linking to the Approval record. Very interesting, I just might have to go update my script now 🙂
