- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 03:40 AM
Hi, so I have a requirement to create a notification which is sent out when the state=implement and planned end date was yesterday. So I have done that using a flow which checks these requirements and triggers the notification. Where I need help is that there is wording which says 'click here' and they should be the ones leading back to the change and closing the open tasks too.
Change Request ${number} has reached it's implementation end date
If the implementation of this change was successful click here to close the change (Note: This will close any open tasks): ${mailto:mailto.closechange}
If the Implementation of this change was backed out or implemented with issues click here to view your change and close manually: ${URI_REF}
so in the 2nd paragraph, where is says click here - that should lead to the change record and close all the open tasks and set state=closed complete. I am doing that using the mailto at the end but how can I add this functionality to the click here words instead? Is there something to be added in the email template (mailto).
Same with the final paragraph. The words 'click here' should lead to the change record, but here it should just lead to the change record and not perform any actions. How can that be done?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 04:52 AM
Hi @snow_beginner ,
1. To generate a link to take user to a particular change record:
Once a user clicks on the 'click here' link in the email, the particular change record will open.
Here are the steps on how to implement this in ServiceNow:
- Create a mail script: The mail script will contain the code that will create the link to the change record.
- Navigate to Emails > Notification Email scripts. The following code snippet can be used as a starting point:
function runMailScript(current, template, email, email_action, event) {
// Get the change record ID.
var changeID = current.sys_id;
// Create the link to the change record.
var link = "https://<instance_name>.service-now.com/change_request.do?sys_id=" + changeID;
// Add the link to the email body.
template.print("<a href='" + link + "'>Click here</a>");
}​
- Save the mail script.
- Call a mail script in an email notification body: To call a mail script in an email notification body, you can use the following syntax:
${mail_script:script_name}
- Here is your message body after applying the mail script:
Change Request ${number} has reached it's implementation end date
If the implementation of this change was successful click here to close the change (Note: This will close any open tasks): ${mailto:mailto.closechange}
If the Implementation of this change was backed out or implemented with issues click here to view your change and close manually: ${mail_script:script_name}
Note: I'm searching solution for "Once the user clicks on 'click here' link, all the change tasks should get closed(i.e. state=closed) which are aligned to particular change_request record"
If this helped you in any way, please hit the like button/mark it helpful. So it will help others to get the correct solution.
regards,
Prasad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 04:52 AM
Hi @snow_beginner ,
1. To generate a link to take user to a particular change record:
Once a user clicks on the 'click here' link in the email, the particular change record will open.
Here are the steps on how to implement this in ServiceNow:
- Create a mail script: The mail script will contain the code that will create the link to the change record.
- Navigate to Emails > Notification Email scripts. The following code snippet can be used as a starting point:
function runMailScript(current, template, email, email_action, event) {
// Get the change record ID.
var changeID = current.sys_id;
// Create the link to the change record.
var link = "https://<instance_name>.service-now.com/change_request.do?sys_id=" + changeID;
// Add the link to the email body.
template.print("<a href='" + link + "'>Click here</a>");
}​
- Save the mail script.
- Call a mail script in an email notification body: To call a mail script in an email notification body, you can use the following syntax:
${mail_script:script_name}
- Here is your message body after applying the mail script:
Change Request ${number} has reached it's implementation end date
If the implementation of this change was successful click here to close the change (Note: This will close any open tasks): ${mailto:mailto.closechange}
If the Implementation of this change was backed out or implemented with issues click here to view your change and close manually: ${mail_script:script_name}
Note: I'm searching solution for "Once the user clicks on 'click here' link, all the change tasks should get closed(i.e. state=closed) which are aligned to particular change_request record"
If this helped you in any way, please hit the like button/mark it helpful. So it will help others to get the correct solution.
regards,
Prasad