Create Bulk RITM and single Request from Excel

Michael51
Tera Guru

Hello All,

I have an Requirement to create Bulk RITM' from Excel Sheet data , in Excel sheet we get Variable values 

1. Name of the Moniter -  variable backend value - u_name_moniter

2. Description - u_description 

So now I need to get the data from Excel sheet and then create one Request for each excel and then create RITM as per the columns in excel , if we have 20 columns we need to create 20 RITM's 

 

can anyone help me with this 

 

@jaheerhattiwale 

1 ACCEPTED SOLUTION

Hi @Michael51 

You can load the excel into staging table and transform using transform map.

In your transform map use below logic in onComplete script.

Try this code :

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

    var impSet = import_set.sys_id ;

    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    var gr = new GlideRecord('u_ritmload'); // give your staging table here
    gr.addQuery('sys_import_set='+impSet);
    gr.query();
    while (gr.next()) {

       var item = cart.addItem('1391a4db070630100b36f6fd7c1ed0c2', 1); //give the catalog item sysid
        cart.setVariable(item, 'mutliline', gr.u_col1 ); //add all your variable details here
        cart.setVariable(item, 'mutliline', gr.u_col2 ); //add all your variable details here

    }
    var req_id = cart.placeOrder();
    gs.info("number"+req_id.number);

})(source, map, log, target);

 

I've tried this and it's working.

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

15 REPLIES 15

jaheerhattiwale
Mega Sage
Mega Sage

@Michael51 Sorry I did not get chance to answer this but nice to see that you got the solution from @Voona Rohila 

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023