Transform map script to check the active and inactive records

nikhitha24
Tera Guru

Hi All,

 

I have a requirement where the data comes from a third party and we are using webservice and it updates in a custom table.

we are using transform maps to map the data into custom table.

Scenario 1 : I have two records in the custom table with same number (number is the unique value) one is active and other was inactive so if there is any update that was coming through the webservice then it has to check the active record and update it and it should ignore the inactive record,.

Scenario 2 : In custom table there is only one record and it was inactive if there is any update receiving then the system should ignore that update.

 

Can you please help me with this.

Thanks in advance

 

11 REPLIES 11

hi @nikhitha24,

 

So in this case it will update the record as per your below query:

 

if(source.u_number == target.number && target.active == true && action == 'update'){
target.anyfield = source.anyfield;
}
rest it will ignore the inactive record.
 
Thanks
Jitendra
Please accept my solution if it works for and thumps up.

Hi Jitendra,

 

I have tried this but not working

Hi,

 

Could you try to target.active == 'true'

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

Not working

Hi @nikhitha24,

 

Could you pls check in this table sys_import_set how the data is inserted and make sure all field data is mapping according to if condition given below;

 

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

    // Add your code here]
    if(source.u_number == target.number && target.active == "true"){
		ignore = false;
	}

})(source, map, log, target);
Please accept my solution if it works for and thumps up.