When i click on the button on email the record will be updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 09:18 AM
i am trying to update the record when the user click on the button on the email.
1) i am trying it by calling the a JavaScript function on on click on the button but the email script is not support JavaScript.
2) i am also trying to call the ui action using link in the a tag on html.
please if anyone of you have any idea about that let me know
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
function test() {
gs.log('function is working ');
var gr = new GlideRecord('sc_request');
if (gr.get(current.sys_id)) {
gr.approval = 'requested';
gr.description = 'now working well';
gr.update();
}
}
var instanceName = gs.getProperty('instance_name');
var approvalLink = 'https://' + instanceName + '.service-now.com/nav_to.do?uri=sc_request.do%3Fsys_id%3D' + current.sys_id + '%26sysparm_action%3Dset_approval';
gs.log('Generated approval link: ' + approvalLink, 'runMailScript');
}
gs.log('outside working');
// var scriptInclude = new closed_state().state_close(current.sys_id);
var btn = `
<table>
<tr>
<td>
<button class = "btn btn-success" onclick=${test()}; style=" width: 200px;
height: 50px;" >${current.number}</button> <br>
</td>
</tr>
<tr>
<td style="padding-top: 10px;">
<button style=" width: 200px;
height: 50px;" >This idea has merit </button>
</td>
</tr>
</table>
`;
email.setSubject('Test Story');
template.print(btn);
));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 12:01 PM
To update a record in ServiceNow from a button click inside an email, you’ll need to implement a secure, tokenized inbound action mechanism (not just a direct link).
✅ Recommended Approach: Use a Scripted REST API + Secure Token
Create a Scripted REST API that updates the target record.
Generate a one-time token (e.g. via GlideEncrypter or sys_cs_token) when composing the email.
Construct the email link to include the token and record sys_id:
https://yourinstance.service-now.com/api/namespace/resource?sys_id=xxx&token=yyy
In the API script, validate the token before updating the record.
⚠️ Avoid:
Direct links that perform updates (glide record update) from email without validation — they’re a security risk and not supported out-of-the-box.
Using Business Rules triggered by “click events” in email — they don’t work that way.
🔐 Why a Token?
ServiceNow does not allow automatic updates just from URL access without authentication or token validation. Otherwise, malicious users could exploit the system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 07:50 PM
that's not how it would work.
When you send email the user has 2 options to update the record
1) user replies to that email, inbound email action on that table runs and updates
2) user is navigated to portal or native page and form is opened and user updates field manually
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