Inbound Email Script to Close RITM

kamchow
Giga Contributor

An email sent out to "Requestor" to reply either "accept" or "reject" when catalog task is closed. This email is triggered from "sc_task" table. Can someone share how to use Inbound Email Action to close RITM if "accept" is replied?

We'd created an Inbound Action on "sc_req_item" table, but didn't work:

find_real_file.png

find_real_file.png

Error message:

Skipping 'Mark Request Item Closed', email is a reply, and the record it matches is not in the Inbound Email Action's table.

1 ACCEPTED SOLUTION

Geoffrey2
ServiceNow Employee
ServiceNow Employee

If the Email Notification is being sent from the sc_task, then the Inbound Action will need to be on the sc_task table too.


If you want it to close the sc_req_item, then you will need to do so with a script on the Action tab:



var ritm = new GlideRecord('sc_req_item');


if (ritm.get(current.request_item)) {


      ritm.state = 3; // Closed Complete


      ritm.work_notes = 'Service Request Accept';


      ritm.update();


}


View solution in original post

9 REPLIES 9

Geoffrey2
ServiceNow Employee
ServiceNow Employee

If the Email Notification is being sent from the sc_task, then the Inbound Action will need to be on the sc_task table too.


If you want it to close the sc_req_item, then you will need to do so with a script on the Action tab:



var ritm = new GlideRecord('sc_req_item');


if (ritm.get(current.request_item)) {


      ritm.state = 3; // Closed Complete


      ritm.work_notes = 'Service Request Accept';


      ritm.update();


}


Prefect! It works... Thanks a lot.


Sorry to bothering you again.



If we want to reopen sc_request to "rework", the script is not working. Am I coding wrong?



var sc = new GlideRecord('sc_request');  


if (sc.get(current.request)) {  


      sc.state = "Rework"; // Rework  


      sc.work_notes = 'Service Request Does Not Accept';  


      sc.update();  


}


Geoffrey2
ServiceNow Employee
ServiceNow Employee

sc_request normally uses the request_state field (not state).   Check the field name and choice values on the form.


Screenshot.png