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

@Voona Rohila , apologies i can retrive date now without any issue but approvals are getting skipped 

Hi @Voona Rohila ,

   This will work if we are loading the data into Servicenow instance. How this needs to be configured On Service Catalog using flow designer? Please provide your inputs on it.

Michael51
Tera Guru

Hello @Voona Rohila  ,

this logic is creating one Request and no of RITM's based on Excel columns , I could see some issues post implemetation 

 

we have approval on (Sc_Request) , it is getting skipped automatically , so here based on our request approval it creates Sc_Task , in this case sc_task is not getting created 

 

Also I have to fill some date on request table by default when this action gets completed ex : I want to set short descirption as Automation request - this will not come from Excel 

 

Also I need to Set some values in Item as well , like requested for I need to set to by default to an user 

 

so can you please help me with this script 

 

 

Ritm's will be attached but once you approve the request then each of the ritm workflow will start.

 


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

Voona Rohila
Kilo Patron
Kilo Patron

Hii

To update short description add this logic

//Update request info. 
var req = new GlideRecord('sc_request');
if(req.get(req_id.sys_id.toString()))
{
    req.description = 'enter description here'; //modify accordingly.
    req.update();
}

Is requested for a variable on the catalog item? If yes then you can pass it 

cart.setVariable(item, 'requested_for', 'sys_id_ofuser'); //add all your variable details here

 


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