- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2019 11:53 PM
Hi all,
I have a requirement to create an sctask from inbound email, this sctask needs to be attached to specific RITM from the subject.
- I have an email template that i use to provide a button on the email to one of our vendor that they will use to reply back to create a task for one specific team - Thus, The subject of the inbound email will have the RITM number as "RITMxxxxx - Deployment requirement"
- The sctask needs to have short description to be the subject of this inbound email, and Description from the email body. Assignment group will be one specific team all the time.
How can i make this possible?
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 11:11 PM
Hello Sam,
You should use below code in your inbound action:
if (current.getTableName() == "sc_req_item") {
var createTsk = new GlideRecord('sc_task');
createTsk.initialize();
createTsk.short_description = email.subject;
createTsk.description = email.body_text;
createTsk.request_item = current.sys_id; // It wil add task under your RITM
createTsk.insert();
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2019 12:35 AM
you can create a catalog item here and attached the workflow in your catalog item, now use cart API in your inbound action to trigger the catalog item. this way you will be able to create catalog task as well as RITM,Request.
Create one workflow on RITM table and use catalog task activity in your workflow so that it can generate catalog task .
Create one Catalog Item with the list of variables which you wanna display on the catalog task as well as RITM.
Create one Inbound action here and use Cart API to trigger that catalog item while sending an email to service-now.
Sample Code:
createRequest();
function Request() {
var cart = new Cart();
var item = cart.addItem('item_sys_id');
var shortd = email.subject;
var empid = email.body.empid;
var empmgr = email.body.manager_id;
var setdesc = email.body_text;
var usern = email.body.username;
var sid = gs.createUser(email.from);
cart.setVariable(item, 'emp_username', usern);
cart.setVariable(item, 'short_description', shortd);
cart.setVariable(item, 'description', setdesc);
//Get the Employee record
var employee = '';
var gr = new GlideRecord("sys_user");
gr.addQuery("user_name", empid);
gr.query();
if (gr.next()) {
employee = gr.sys_id;
}
//Get the Manager record
var manager = '';
var grm = new GlideRecord("sys_user");
grm.addNotNullQuery("user_name");
grm.addQuery("user_name", empmgr);
grm.query();
if(grm.getRowCount() != 0) {
if (grm.next()) {
manager = grm.sys_id;
}
}
else {
//If no manager set to HR Workday
manager ='workday_user_sys_id';
}
cart.setVariable(item, 'ref_employee', employee);
cart.setVariable(item, 'requested_for', manager);
var rc = cart.placeOrder();
var ritm = new GlideRecord('sc_req_item');
ritm.get('request', rc.sys_id.toString());
var em = new GlideRecord('sys_email');
em.get('uid', email.uid);
GlideSysAttachment.copy('sys_email', em.sys_id.toString(), ritm.sys_class_name, ritm.sys_id.toString());
gs.log('Email Sys Id : ' + em.sys_id.toString(), 'email');
gs.log('Current Sys Id : ' + current.sys_id.toString(), 'email');
gs.log('RC Sys Id : ' + rc.sys_id.toString(), 'email');
gs.log('RC Class Name : ' + rc.sys_class_name, 'email');
}
event.state = "stop_processing";
Refer the below link for further information about Cart API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2019 02:52 PM
Hi, Thanks for the quick reply. However this is part of the existing catalog item, please see the detail situation below: We have a catalog item for a custom software, once submitted after approval - as part of the workflow email goes out to external vendor to add license for this request - but 1 in 10 request the software may be required to be installed on the computer - this is installed by desktop team internally, thus, I am giving vendor a button on that email that they can reply back telling what version software requires to be installed on users machine, which then I need a setup with inbound action to create task on that existing rite request to the desktop team with subject = short description and body = description. As the button is done through the email template I am putting the ritm number in the subject as "RITMxxxxx - Deployment requirement". I have an activity in the workflow that will check for any open sctask and workflow will wait till that is completed - so no issue in creating sctask manually. Is this possible? Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2019 03:14 PM
Can you share a screenshot of your workflow?
Think about this...
If the workflow goes to scan itself for an open sc_task, it won't find one. So you'd have to hold the workflow from processing using something else. The notification going out in the workflow goes to the vendor...but if they never respond...then your workflow sees no open task and would end...
So, you'd need to possibly create a yes/no variable (with "none") (and use UI policy to hide it on the catalog item, but visible on the RITM/Task levels) on this catalog item for "installation required" and have your workflow wait for this field to have either a Yes or No value. So that way it sits. Then, in your inbound action, you look to see if this response in about specific catalog item "Software" and you evaluate their response (whether they are just attaching a license OR if they are attaching a license and need installation)...either way, you then set that installation required variable to either yes or no via script in inbound action. Then have your workflow move forward once that variable is either yes or no and build your workflow path accordingly to create the sc_task and you've already got the ability to label the short description and all that.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 11:11 PM
Hello Sam,
You should use below code in your inbound action:
if (current.getTableName() == "sc_req_item") {
var createTsk = new GlideRecord('sc_task');
createTsk.initialize();
createTsk.short_description = email.subject;
createTsk.description = email.body_text;
createTsk.request_item = current.sys_id; // It wil add task under your RITM
createTsk.insert();
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade