The CreatorCon Call for Content is officially open! Get started here.

Bulk Create Request

Alison11
Mega Expert

Hello,

 

We are required to bulk create RITMs from values in an excel file. Currently, I already have a source table and transform map with the ff onBefore script:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
    createRequest();

    function createRequest() {
        var cart = new Cart();
        // add in cart, substitute your cat item sys_id
        var item = cart.addItem('xxxxxxxxxx'); //catalog item sys_id

        //Set Variables in your Cart Item
        cart.setVariable(item, 'requested_for', gr.u_requested_for);
        cart.setVariable(item, 'employee_id', gr.u_employee_id);
        cart.setVariable(item, 'department', gr.u_department);

        var rc = cart.placeOrder();
    }
})(source, map, log, target);

 

However, it's not running as expected. I've tried setting the target table to: both Request [sc_request] and Request Item [sc_req_item] but I only get blank REQs and RITMs.

I've already seen these and also based the script from them:

 

Am I missing something or is there a different way to bulk create requests that would also trigger the workflow accordingly?

 

Thank you in advance!
Alison

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

cart.setVariable(item, 'requested_for', gr.u_requested_for); // Where is gr coming from? itz not defined anywhere. it shud be returning undefined

Regards
Harish

Hello Harish,

 

Thanks for pointing that out! Didn't notice, sorry about that.

 

I updated it to below script but it's still creating blank requests:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
    createRequest();

    function createRequest() {
        var cart = new Cart();
        // add in cart, substitute your cat item sys_id
        var item = cart.addItem('xxxxxxxxxx'); //catalog item sys_id

        //Set Variables in your Cart Item
        cart.setVariable(item, 'requested_for', source.u_requested_for);
        cart.setVariable(item, 'employee_id', source.u_employee_id);
        cart.setVariable(item, 'department', source.u_department);

        var rc = cart.placeOrder();
    }
})(source, map, log, target);

 

Regards,
Alison