Thank you for clarifying that this is a ServiceNow environment.
To address the issue where some approval emails are sent without the request item reference link, here are ServiceNow-specific steps and checks you can perform:
1. Verify the Email Notification Template
-
Go to System Notification > Email > Notifications.
-
Open the specific notification used for approval emails.
-
Check the Email Template or the message body under the What will it contain? section.
-
Look for the variable or snippet used to display the request item reference link, typically something like:
${URI_REF}
or referencing the current GlideRecord fields like:
Request Number: ${request.number}
-
Make sure that the template uses the correct field or script to generate the link.
2. Check if the Reference Link Token or Script is Correct
-
If the link is built using ${URI_REF}, it depends on the current record context.
-
For approval notifications, often the notification is triggered on the Approval [sysapproval_approver] table or the Requested Item [sc_req_item] table.
-
Verify if the notification is being sent from the correct table context and if the variables populate correctly.
-
If the notification triggers from the Approval table (sysapproval_approver), you might need to use a script snippet to build the request item link dynamically. For example, use a script like:
var requestLink = "";
var reqItem = current.document_id.getRefRecord();
if (reqItem.isValidRecord()) {
requestLink = "<a href='" + gs.getProperty('glide.servlet.uri') + reqItem.getLink() + "'>" + reqItem.number + "</a>";
}
answer = requestLink;
-
Ensure that the script or variable fetching the request item record is working correctly in all approval emails.
3. Check the Trigger Condition on Notifications
-
In the notification record, review the When to send section.
-
The condition might restrict sending the notification in some approval states or for certain kinds of requests where the reference link isn't set.
4. Review the Approval Records
-
Confirm the document_id field in the approval record points correctly to the requested item (sc_req_item).
-
Sometimes if the approval is linked to a different table or the document_id is missing, the link cannot be populated, resulting in missing reference links.
5. Test Using “Preview Notification”
-
In the notification record, use the Preview Notification feature.
-
Select an approval record that does not include the link and one that does.
-
Check how the variables render in each case.
6. Check Business Rules or Script Includes Affecting Emails
-
Sometimes, business rules or script includes modify notification behavior or the current context.
-
Confirm if any scripts are interfering with variable population.
Summary
- Missing reference links usually mean the notification lacks proper context (record or data) to build the link.
- Recheck notification table, variables and conditions.
- Use scripting to explicitly fetch and build the request item link when the notification triggers from approval records.
- Always test with Preview Notification to confirm variable rendering.
If you want, you can share your notification script/body or the table on which the notification triggers, and I can help you craft the correct variable or script.
Let me know if you want a sample script or assistance reviewing your notification!