- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 05:36 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 03:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 03:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 09:42 PM
Hi @Voona Rohila ,
does this create Request as well ? How should I create Request and associate all RItM to it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 02:47 AM
Yes the above logic creates one request with multiple RITM'S.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 03:49 AM
Thanks will implement this and will let you know the output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 02:11 AM
@Voona Rohila , I could not get data from excel sheet , it is showing as undefined in the variable name , how can get the description information from excel and then pass that into variable