How to submit the Record producer using Background Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 04:06 AM
Hi everyone,
We have requirement, that with one table field values need to submit a record producer. when I'm trying to submit a record producer using Cart() below script for your reference. please share your solutions and suggestions with me
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('13f86d5333271a1422cac0255d5c7bd8', 1);
cart.setVariable(item, 'order', gr.variables.order);
cart.setVariable(item, 'plant', gr.variables.plant);
cart.setVariable(item, 'planner_name', gr.variables.planner_name);
cart.setVariable(item, 'equipment', gr.variables.equipment);
cart.setVariable(item, 'proirtiy', gr.variables.proirtiy);
cart.setVariable(item, 'ensure_material_availiablity_as_stock_item', gr.variables.ensure_material_availiablity_as_stock_item);
cart.setVariable(item, 'total', gr.variables.total);
cart.setVariable(item, 'cost_center', gr.variables.cost_center);
cart.setVariable(item, 'reference_pr_po_no', gr.variables.reference_pr_po_no);
cart.setVariable(item, 'requester_details', gr.variables.requester_details);
cart.setVariable(item, 'details', gr.variables.details);
var rc = cart.placeOrder();
but request inserting on RITM table. please provide me the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 04:37 AM
Its working fine for me its created a Req and RITM separately.
As you can see in the pic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 04:42 AM
actually it is creating as RITM, but we have custom table request should be created on that table why bcz record producer created on that custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 05:39 AM
Hello @lakshman nalla
I have worked with this requirements where we needed custom table to populate based on record producer data.
Please work out using Flow designer and BR - it will be much more efficient.
Kindly mark my answer as helpful and accept solution if it helped you in anyway,
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 06:26 AM
don't use cart API as it will create REQ and RITM
check this link and enhance it further.
How to Trigger change workflow/record producer from transform 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