doing script for creating catlaog request by email inbound action script

sainath reddy
Tera Contributor

I have a requirement for scripting by using email inbound action I have to raise a catalog request through an emai.I'm writing this script but this is not working.Are there any complications in this code.can anyone let me know.Even though it is reflecting in system logs a created.Yet it creating under Incident table, even though I Gave table as sc_request in inbound email action.

 

createRequest();
function createRequest() {
             sys_email.target_table = 'sc_request';
             var short_description = email.subject.toString();
             var body = email.body_text.toString();
             var message = "received from: " + email.origemail + "\n\n" + body;
             var cat_item = 'hgi434nmrXXXXXXXXXXX'; 
             //var name = gs.getUser().getUserByID(email.from_sys_id).getDisplayName();
              
             var cart = new sn_sc.CartJS();
             var item = {
                 'sysparm_id': cat_item,
                 'sysparm_quantity': '1',
                 'variables': {
                     'notes': message
                 }
             };
             cart.addToCart(item);

             var request = {
                 'special_instructions': '',
                 'requested_for': requested_for,
                 'delivery_address': '',
             };
             var requestDetails = cart.submitOrder(request);

             var reqSysID = requestDetails.request_id;

             var rec = new GlideRecord("sc_req_item");
             rec.addQuery("request", reqSysID);
             rec.query();
             if (rec.next()) {
         
                 rec.short_description = short_description;
                 rec.update();
             }
         }
7 REPLIES 7

when Email is sent to create Request.In Emais->system logs->emails.when i check it here it is going as Target : Incident

 

did u check this ??

HemanthM1_0-1692284548878.png

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

did you check these logs whats happening when inbound runs 

HemanthM1_0-1692362469895.png

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025