Question on inbound action to create request
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 10:04 PM
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.
Could you please help me on this to get the proper solution.
Thanks
0 REPLIES 0
