- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 06:20 AM
Hello,
I need to add a button in email notification triggered to user, button called "Close Request" when user click on the button it should update the RITM record state to "Closed Completed"
How can I achieve this. Could someone please let me on this
Thanks in advance 😃
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 03:38 AM - edited 01-25-2025 03:40 AM
Hello @anvitha ash
Sorry for delay in response.
After going through entire overnight discussion do find updated things for your requirement.
Over email notification you need two buttons so the HTML source code as below:
<table style="border-collapse: collapse; width: 100%;" border="0">
<tbody>
<tr>
<td style="width: 100%; height: 52px; padding-top: 16px;"><span id="closerequest" class="btn" style="border-radius: 4px; border: 1px solid #4f52bd; padding: 6px 16px; color: #4f52bd;">${mailto:mailto.btn.closeRequest}</span><span id="createtaskforrequest" class="btn inverse" style="margin-left: 16px; border-radius: 4px; border: 1px solid #4f52bd; padding: 6px 16px; background-color: #4f52bd; color: #fff;">${mailto:mailto.btn.createtaskforrequest}</span></td>
</tr>
</tbody>
Then you will need two email template which will showcase details over your button and when click it will open a mailbox window so user will send email to ServiceNow instance.
Email template is created under table = sysevent_email_template
First will be for Close Request which will be as below:
Second will be Create Task which will be as below:
Email Preview will be as below:
Now when any button is click it will open an outlook window to reply back to our instance which will look as below:
Now to when this email comes in ServiceNow we need inbound action which I have already provided above in reply but to save scroll time here we go again with same.
Inbound action named as Create Task on table sc_task with type as reply and condition as mail.subject.indexOf('Create Task') > -1 and script will be as below
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.setValue('parent', email.instance);
gr.setValue('short_description', 'New Task for RITM ' + email.instance);
gr.insert();
Inbound Action with name as Close Request, for table sc_req_item with type as Reply and condition something as email.subject.indexOf('Close Request') > -1 which checks whether email subject is having word as Close Request and then in script field you will need to put code to update ritm to close when email is process so it will be as below.
var gr = new GlideRecord('sc_req_item');
if (gr.get(email.instance)) {
gr.setValue('state', 3); // 3 is the value for "Closed Complete"
gr.update();
}
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 10:02 AM
@anvitha ash - Inbound email working or not you can see over email logs related list as showcase over previous response. Did you saw that? Please confirm if you see Processed or Skip keyword in front of inbound email action name in log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 10:25 AM
Could you please help in navigation part to check the log if it is skipped or processed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 10:31 AM
I have checked in system mailboxes> outbox
I can see the email state = processed
Reply type =email
Mailbox = recieved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 11:03 AM - edited 01-26-2025 11:05 AM
@anvitha ash Now open that email record recieved in instance and scroll to bottom and check email logs related tab. See same screenshot provided earlier in previous response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 11:13 AM - edited 01-26-2025 12:43 PM
System logs > emails> then I Opened the email which I recieved and type = recieved
In related list email log, I have checked the condition: message contains with my inbound action name, and i didn't get any records with my inbound action name