- 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 05:31 AM
@Viraj Hudlikar everything is working as expected.. if i append some text in the email body it is also updating the current record.
Now the problem is inbound action not updating any fields in the table. To verify i have added logs here and there. But none of the logs are been populated in the logs table ..I'm suspecting that inbound is not getting triggered. I have verified the condition as well but no luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 06:24 AM
Hello @anvitha ash
Great to hear its 90% working just 10% remaining. Don't lose hope be happy you learnt something new and who is reading hit like if this post is read by you 😉
Okay now let me know which field updates are not happening. Did you receive email in your instance? If yes open that email which is received check under email logs related list and search for your inbound email action name with * symbol see image below.
For me when this email came it got processed as my inbound email action was matched as per condition setup. See what you are seeing in such case? If you see skipped for your inbound action name, then some other inbound is taking precedence and performing action as define there.
Also, here is sneak peak of inbound email actions how it looks over my instance.
Now you may think under actions tab I have both script and field actions kept its just to showcase we can use what is simple to config as ServiceNow go with saying low-code or no-code.
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 07:47 AM
Email is receiving
When we reply to the email let say, once I click on the "Cose request" button it is redirecting me to reply.when I add my message let's say "we are good go close the requested item" and when I send it , then same comments which I added in the email body is updating in the worknotes of the ritm and I can see the email is also recieved in the worknotes of the RITM, but only thing it is not updating any of the RITM record fields. Ideally it should update the state of RITM since I didn't work i tried to update other fields as well but it didn't worked for any of the RITM record fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 08:33 AM
Hello @anvitha ash
The email notification setup is for sc_req_item table only? when you replying back over email try to avoid put down any notes and see does it update state, I suspect that if RITM is commented it overriding the state change happening back to WIP.
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 09:09 AM
Notification set-up in sc_req_item table and also inbound as well
I tried both ways by keeping reply email as empty as well as added some text to it
Since the state field was not getting updated, then I tried to update other fields like description or short description but, it didn't worked for description field as well
I added log statement in the inbound action script whether to check if it is triggering the script or not but none of my ligs got printed in the log table . I'm suspecting that the inbound itself is not working