Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Question on inbound action to create request

suru2
Tera Contributor

Hi All,
I have one requirement on creating request via inbound action, here i have written inbound action sc_request table to create a request, please find the below code which i have written:

 

// Parse the email body to extract item variables
var emailBody = current.body_text; // Assuming 'current' is the GlideRecord representing the email record
var contractorName = ''; // Initialize variables
var manager = '';
var requestDescription = '';

// Use regular expressions or other parsing methods to extract item variables from the email body
// Example regular expression to extract contractor name
var contractorNameRegex = /Contractor Name: (.*)/i;
var contractorNameMatch = emailBody.match(contractorNameRegex);
if (contractorNameMatch) {
    contractorName = contractorNameMatch[1];
}

// Similar parsing for other variables like manager and request description

// Create the request item in the cart
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('030bfcd11b3f6050772853de034bcbb5'); // Assuming this is the item ID
cart.setVariable(item, 'contractor_name', contractorName);
cart.setVariable(item, 'manager', manager);
cart.setVariable(item, 'request_description', requestDescription);

// Place the order and create the request
var rc = cart.placeOrder();
gs.info('Request created: ' + rc.number);

 

Request is created but RITM item variable value showing empty.
Please find below snapshot.

suru2_0-1709618585387.png

 

suru2_1-1709618585379.png

 

Could you please help me on this to get the proper solution.

 

Thanks

 

0 REPLIES 0