- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 08:46 PM
hi
I am trying to create a req,ritm and task with the help of inbound action where the moment when the email is in the sn it should create req,ritm and task related to it and i got a post from where i got the script but it need to be modified as it not working the way i want to......below is the script.......please help me where i ahve to make changes:
createRequest();
function createRequest() {
//Read From
var frm='';
if(email.body.from != undefined) {
frm = email.body.from.toString();
}
var cart = new Cart();
// add in cart, substitute your cat item sys_id
var item = cart.addItem('12345678901234567890'); // sys_id of the item
cart.setVariable(item,'description',email.body_text);
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
var rc = cart.placeOrder();
gs.log('Request Crested is:'+rc.number);
gs.log("SR creation request" + frm);
if(frm != ''){
var ritmSysID = "";
var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", rc.sys_id);
ritmRec.query();
if(ritmRec.next()){
ritmSysID = ritmRec.sys_id;
//ritmRec.description = email.body_text;
ritmSysID.short_description = email.subject;
}
var emailRec = new GlideRecord("sys_email");
emailRec.addQuery("uid", email.uid);
emailRec.orderByDesc("sys_created_on");
emailRec.query();
if(emailRec.next()){
GlideSysAttachment.copy("sys_email", emailRec.sys_id, "sc_req_item", ritmRec.sys_id);
}
rc.update();
}
}
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 09:04 PM
Hey Dell,
You can refer below mentioned blog to achieve your requirement. I tried it and it helped me do exactly what you want to do.
Refer: https://community.servicenow.com/community?id=community_blog&sys_id=c25da629dbd0dbc01dcaf3231f961933
Please mark my answer Helpful and Correct.
Thanks and Regards:
Utpal Dutta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 09:04 PM
Hey Dell,
You can refer below mentioned blog to achieve your requirement. I tried it and it helped me do exactly what you want to do.
Refer: https://community.servicenow.com/community?id=community_blog&sys_id=c25da629dbd0dbc01dcaf3231f961933
Please mark my answer Helpful and Correct.
Thanks and Regards:
Utpal Dutta