How to add SCTASK URL in notification which is created on sc_req_item table ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 08:26 PM - edited 01-08-2025 08:27 PM
Hello,
I have requirement to add SCTASK URL in notification email body which is created on sc_req_item table.
Please suggest the how to achieve it.
If it is achieved by email script please share.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 08:57 PM
To create a notification for the Requested Item [sc_req_item] table, set the trigger condition to "on Record Inserted." Specify the intended recipient(s), such as "Requested for," "Assigned to," or any user field associated with the record. In the "What it will contain" tab:
- The ${URI} variable in the email body dynamically generates the URL pointing to the current record (in this case, the SCTASK).
- Recipients clicking the link in the email will be redirected to the SCTASK form in ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 09:43 PM
something like this but please enhance it
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.sys_id);
gr.query();
while (gr.next()) {
var link = gs.getProperty('glide.servlet.uri') + 'sc_task.do?sys_id=' + gr.sys_id;
template.print('<a href="' + link + '">Link to SCTASK</a><br/>');
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader