Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Inbound email action creating two RITMs

Sam198
Mega Guru

Hi all,

I have the below inbound email action and workflow setup to create RITM/SCTASK, however, it's creating two RITMs and not adding the email subject and body to the RITM or SCTASK. Can someone take a look and see where i am missing anything?

find_real_file.png

Currently, i would like inbound email to create a RITM and SCTASK from that email. We do not use REQ and it is pre approved. i have used the below script from this thread https://community.servicenow.com/community?id=community_blog&sys_id=c25da629dbd0dbc01dcaf3231f961933

Inbound email action script > on table sc_req_item

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

createRequest();

function createRequest() {

var cart = new Cart(); //calling the cart API

var item = cart.addItem('52a899c4db343700ee3f11b14a9619ab'); //sys_id of the catalog item I want to fire

cart.setVariable(item, 'subject', email.subject); //sets catalog variable to the email's subject

cart.setVariable(item, 'emailbody', email.body_html); //sets catalog variable to email's body

var rc = cart.placeOrder(); //this launches the catalog item, and creates a request object. rc = the request object

updateRITM(rc.sys_id); //call a function immediately to update the ritm. This must be a nested function, otherwise inbound actions get weird.

//also, we're passing the sys_id of the request so we know what RITM to grab.

}

function updateRITM(req){

var ritm = new GlideRecord('sc_req_item');

ritm.addQuery('request', req); //req is what we passed from the previous function. the sys_id of the request.

ritm.query();

while (ritm.next()){

ritm.variables.description = email.body_html;

ritm.variables.short_description = email.subject;

ritm.update();

}

}

event.state="stop_processing"; //stop evaluating inbound actions.

})(current, event, email, logger, classifier);

 

The workflow of the catalog item that is in the var item = cart.addItem is as below:

Table: sc_taskfind_real_file.png

 

1 ACCEPTED SOLUTION

Sam198
Mega Guru
I have got this working by changing inbound action table to sc_req and adding current.update(); under Cart.placeorder();

View solution in original post

1 REPLY 1

Sam198
Mega Guru
I have got this working by changing inbound action table to sc_req and adding current.update(); under Cart.placeorder();