- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2025 06:46 AM
I'm trying to submit a catalog item(already created) through an inbound action script:
Type: New
Target Table: Request (sc_request)
Action Type: Record Action
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('acfb58a73bec6e100d0f8c9c24e45aa0'); //Multifactor Authentication Compliance
cart.setVariable(item, 'email_subject', email.subject);
cart.setVariable(item, 'email_body', email.body_text);
gs.log('Test Subject: ' + email.subject);
gs.log('Test Body: ' + email.email_body_text);
var rc = cart.placeOrder();
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request',rc.getValue('sys_id'));
grRITM.query();
if(grRITM.next()) {
grRITM.setValue('sys_created_by', ' Inbound Email Action');
grRITM.setValue('contact_type', 'email');
grRITM.setValue('short_description', 'Multifactor Authentication Compliance' + ' - ' + email.subject);
grRITM.setValue('description', 'Text from Email' + ' - ' + email.body_text);
//Add Attachment(s)
GlideSysAttachment.copy('sys_email', sys_email.sys_id, 'sc_req_item', grRITM.sys_id);
grRITM.update();
var emailGR = new GlideRecord("sys_email");
emailGR.addQuery("sys_id", sys_email.sys_id);
emailGR.query();
if(emailGR.next()){
emailGR.instance = grRITM.sys_id;
emailGR.target_table = "sc_req_item";
emailGR.update();
}
}
})
This created a Request record but does not create an RITM. If I switch the Target Table to sc_req_item, it creates an RITM but does not associate with a catalog item. It's a blank RITM with no information.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 04:20 AM
@Ankur Bawiskar the script I originally posted actually works, the issue was during my testing I was not adding the user email from my inbound action criteria into the test email within ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2025 06:51 AM
the Cart API should create both REQ and RITM
Did you try that script in background script?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2025 06:54 AM
another way is to use flow and check these links
Create RITM through inbound action by parsing mail body
https://pathwayscg.com/scripting-for-the-servicenow-cart/
Submit and close a catalog item request from inbound email -> response from Amit
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2025 07:00 AM
Yes, that's what I thought it would do as well if I set the table to sc_request, but it is not. I also double checked the sys_id of that catalog item thinking that could be the issue.
We do not use flow designer here so that won't work for us.
Ran as background script and it did not work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2025 07:59 PM
then it's not an issue with inbound table type REQ or RITM
If it works in background script then it will work in inbound action as well
Is there any user criteria applied on that catalog item?
share the background script here
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader