Create multiple RITM's from excel using flow designer with out empty records

AnilM99
Tera Expert

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

AnilM99_0-1734946314844.png

AnilM99_1-1734946352765.png

 

My flow Designer is:

AnilM99_2-1734946458769.png

 

help me on the process.

Thanks,

Anil!

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@AnilM99 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

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. 

AnilM99_0-1734950928640.png

 

 

 

@AnilM99 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@AnilM99 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader