Inbound Email Action: error did not create or update sc_req_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 01:29 AM
hi there,
I'm trying to create a request for people being on-boarded using an inbound email action and take the information from the email into add it to the requested item but for some reason this isn't running and I get the error:
Here are the conditions:
Here is the script:
createRequest();
function createRequest() {
var cart = new Cart();
var item = cart.addItem('26ce6d3847759110f42ad0e8736d43b0');
//if (email.body.full_name != undefined && email.body.u_phone != undefined && email.body.job_title != undefined)
cart.setVariable(item, 'name', email.body.name);
cart.setVariable(item, 'employee_id', email.body.employee_id);
cart.setVariable(item, 'job_title', email.body.job_title);
cart.setVariable(item, 'department', email.body.department);
cart.setVariable(item, 'manager', email.body.manager);
cart.setVariable(item, 'hire_date', email.body.hire_date);
cart.setVariable(item, 'worker_type', email.body.worker_type);
var sysUsr = new GlideRecord("sys_user");
sysUsr.addQuery("name", '=', email.body.manager);
sysUsr.query();
if (sysUsr.next()) {
ritm.u_cf_user = sysUsr.sys_id;
var scReq = new GlideRecord("sc_request");
scReq.addQuery("sys_id", req);
scReq.query();
if (scReq.next()) {
scReq.requested_for = sysUsr.sys_id;
scReq.update();
}
var rc = cart.placeOrder();
}}
Can anyone advise as to why this is not running
Many thanks,
Alex

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 02:19 AM
In the last if check
ritm.u_cf_user = sysUsr.sys_id;
have you defined the ritm variable in the script anywhere?