- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello!
I'm working on a notification for a rejected approval, and have been asked to include a link back to the record that was rejected. This normally would be pretty straightforward, but what I'm up against is this is a custom App (extended from Task) and we only want the records interacted with in their own Workspace. I do have an email script that builds the URL so that a notification like "Task assigned to your group" takes them into the workspace, but I have no idea how to effectively do this from the Approvals table. I'm doing the notification from there because we want to include the comments from the rejection in the notification. Any assistance or suggestions are greatly appreciated.
Thanks,
Erik
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey @Erik Nelson
Since the notification is being triggered from sysapproval_approver, you can still generate a Workspace link to the rejected record by using the sysapproval reference field. That field points to the record that was approved/rejected, so you can retrieve the target record and build the Workspace URL dynamically.
Create an Email Script and use something similar to the following:
(function runMailScript(current, template, email, email_action, event) {
var targetRecord = current.sysapproval.getRefRecord();
if (!targetRecord || !targetRecord.isValidRecord()) {
template.print("Unable to generate record link.");
return;
}
var baseUrl = gs.getProperty('glide.servlet.uri');
// Update the workspace name/path to match your environment
var workspaceUrl = baseUrl +
'now/workspace/my_workspace/record/' +
targetRecord.getTableName() + '/' +
targetRecord.getUniqueValue();
template.print(
'<a href="' + workspaceUrl + '">Open Rejected Record</a>'
);
})(current, template, email, email_action, event);
Then reference the Email Script in your notification:
${mail_script:workspace_link}*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
share screenshots and also the email script
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey @Erik Nelson
Since the notification is being triggered from sysapproval_approver, you can still generate a Workspace link to the rejected record by using the sysapproval reference field. That field points to the record that was approved/rejected, so you can retrieve the target record and build the Workspace URL dynamically.
Create an Email Script and use something similar to the following:
(function runMailScript(current, template, email, email_action, event) {
var targetRecord = current.sysapproval.getRefRecord();
if (!targetRecord || !targetRecord.isValidRecord()) {
template.print("Unable to generate record link.");
return;
}
var baseUrl = gs.getProperty('glide.servlet.uri');
// Update the workspace name/path to match your environment
var workspaceUrl = baseUrl +
'now/workspace/my_workspace/record/' +
targetRecord.getTableName() + '/' +
targetRecord.getUniqueValue();
template.print(
'<a href="' + workspaceUrl + '">Open Rejected Record</a>'
);
})(current, template, email, email_action, event);
Then reference the Email Script in your notification:
${mail_script:workspace_link}*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you! I had the original setup in place for creating the link, just didn't know how to extend it for approvals.