Create multiple RITM's from excel using flow designer with out empty records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 01:48 AM
Hi Team,
We have to create multiple RITM's from EXCEL using flow designer. I used Transform map onComplete Script.
Script:
(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);
The above script is working when i am using data load and run the transform map.
if am using the flow designer, the empty records are creating and the same RITM numbers are mapped to import set Target record
My flow Designer is:
help me on the process.
Thanks,
Anil!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 02:06 AM
in your onBefore transform script set ignore=true.
the reason why extra empty record is getting created is because you might have given target table as sc_req_item during your transform map
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
ignore = true;
})(source, map, log, target);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 02:49 AM
Thanks for the reply.
As per your comment, I changed the script to OnBefoe and add ignore = true;
In excel spread sheet we have 3 columns, so it creating each column as 3 RITMS and total 9 RITMS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 04:06 AM
if excel has 3 rows then you want 3*3 = 9 RITMs?
if yes then you should keep your onComplete as onAfter script
Create fresh onBefore so that it doesn't create empty RITM
Also share your transform map configuration screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:21 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader