Ignore Records in a transform Map

ursnani
Giga Guru

Hi,

I am trying to load data and run a transform map to load them to target table. My requirement is if I try loading the data which I am not expecting then it should just ignore the record and update the remaining records.

 

Sample Data is as below.

find_real_file.png

 

I am trying to run a onBefore Script and checking for the Number which will always start with certain prefix like INC or SINC and ignore SrINC records. Below is the code which I am using when I run the transform map.

var str = source.u_number;
    var incregex = /^INC/;
	var sniregex = /^SINC/;
	
	
	if(!incregex.test(str) || !sniregex.test(str)){
		
		ignore = true;
	}

 

Any help on this is very much appriciated.

 

Thank you in Advance

1 ACCEPTED SOLUTION

Try this

It should work - onBefore transform map script

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

	var str = source.u_number;		
	str = str.replace(/[0-9]/g, ''); //replace all numeric part
	if((str == 'INC' || str == 'SINC') && (action == 'insert' || action == 'update'))
        {		
		}
	else
		{
		ignore=true;
		}

})(source, map, log, target);

Let me know then if you need any further help

Regards,
Anshu

View solution in original post

7 REPLIES 7

Anshu_Anand_
Kilo Sage
Kilo Sage
var str = source.u_number;		
	if(str.includes('INC') || str.includes('SINC'))
        {
		
		ignore = true;
	}

Try this.

It will ignore the prefixes records starting with INC and SINC

If works, please mark answer as correct

Regards,
Anshu

Hi Anshu,

 

I want to Ignore other records other than INC and SINC.

we have a feed coming into our system which have many records that have Many Prefixes and I need to ingore them all and Update only those records with INC and SINC.

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

	var str = source.u_number;		
	if((str.includes('INC') || str.includes('SINC')) && (action == 'insert' || action == 'update'))
        {		
		}
	else
		{
		ignore=true;
		}

})(source, map, log, target);

can you try this onBefore transform map script .

It should work.

Let me know if its not, else mark the answer as correct

 

Regards,
Anshu

Try this

It should work - onBefore transform map script

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

	var str = source.u_number;		
	str = str.replace(/[0-9]/g, ''); //replace all numeric part
	if((str == 'INC' || str == 'SINC') && (action == 'insert' || action == 'update'))
        {		
		}
	else
		{
		ignore=true;
		}

})(source, map, log, target);

Let me know then if you need any further help

Regards,
Anshu