RITM field not poulating from inbound email rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @Sooriya3 ,
Please check below script
var req = new GlideRecord('sc_request');
req.initialize();
req.requested_for = email.from;
req.short_description = "Request from email: " + email.subject;
req.description = "Email body: " + email.body_text;
req.insert();
gs.log('Request created: ' + req.sys_id);
var ritm = new GlideRecord('sc_req_item');
ritm.initialize();
ritm.request = req.sys_id;
ritm.short_description = req.short_description;
ritm.description = req.description;
ritm.cat_item = 'catalog_sys_id';
ritm.insert();
gs.log('RITM created: ' + ritm.sys_id);
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello @Sooriya3 ,
You forgot to add ritm.insert() after initializing the RITM details.
Just like you called req.insert() at the beginning of the log line 7, it's important to also call ritm.insert() after setting up the RITM object. This ensures the RITM data is properly saved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
The reason your sc_req_item record description isn’t populating even though the parent sc_request is is likely because you’re inserting the RITM manually via initialize()/insert() instead of going through the catalog flow which handles the correct relationships and triggers; by default when you use the catalog API (for example var cart = new sn_sc.CartJS(); cart.addItem(...); cart.setVariable(...); var rc = cart.placeOrder();) the request and request item are created together and you can then reliably update the description and short_description on the RITM after the API completes.
If you stick with your manual script approach you should confirm that you’re: properly linking the RITM to the REQ via ritm.request = req.sys_id, then filling the fields after insert() of the REQ and before the insert() of the RITM, and lastly confirming that the description field on the RITM table is writable (no UI policy/business rule overwriting/clearing it)......
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
that's not an ideal way to create REQ and RITM as you are using GlideRecord
It won't trigger the associated Workflow or Flow linked to that item
your can use Inbound flow low-code, no-code approach and use "Submit Catalog Item Request" flow action to generate REQ, RITM and once that item is submitted it's associated Flow/Workflow will create the catalog task
check this link for help
Easiest way to Trigger Catalog Item Request via Inbound Email
OR
You can also use inbound action and CartJS API to submit that catalog item
something like this
var cart = new sn_sc.CartJS();
var request1 = {
'sysparm_id': 'ec10f4fd47266110b81cd855d36d4308', // sys_id of catalog item
'sysparm_quantity': '1',
'variables': {
'requested_for': '8efae6cbdb038b00d6563cae7c961',
'short_description': 'my short description',
'description': 'my description'
}
};
var checkoutInfo = cart.checkoutCart();
var cartDetails = cart.orderNow(request);
var requestDetails = cart.submitOrder(request);
// you can parse the above JSON and query RITM and then update the fields you want
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
