The CreatorCon Call for Content is officially open! Get started here.

Inbound Email Action: error did not create or update sc_req_item

Alex Saager1
Tera Contributor

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:

 

AlexSaager1_0-1680682394259.png

 

Here are the conditions:

AlexSaager1_1-1680682394272.png

 

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

1 REPLY 1

Sandeep Rajput
Tera Patron
Tera Patron

In the last if check 

 ritm.u_cf_user = sysUsr.sys_id;

have you defined the ritm variable in the script anywhere?