How to submit the Record producer using Background Script

lakshman nalla
Tera Contributor

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.

4 REPLIES 4

PraveenK1149237
Tera Expert

Its working fine for me its created a Req and RITM separately. 

PraveenK1149237_0-1741606556285.png

As you can see in the pic 

PraveenK1149237_1-1741606639548.png

 

 

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.

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

Ankur Bawiskar
Tera Patron
Tera Patron

@lakshman nalla 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader