- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2019 12:44 AM
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?
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_task
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2019 05:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2019 05:41 PM
