Transform script not working while loading the data , getting ignored

Abhilasha G T
Tera Contributor

Hi Team,

 

I have written on before transform script like below,

 

if(source.u.dns_name.contains('-sd-')){

    ignore = false;

    }

    else {

    ignore = true;

 

    }

 

Requirement is :

some data having DNS Name field contains,  -sd- , those data should insert into the target table, while loading

AbhilashaGT_1-1714476987425.png

remaining data should get ignored , but its not happening all the data is getting ignoring now,

how to trouble shoot this,

 

Regards,

Abhilasha G T

 

 

 

 

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Abhilasha G T ,

 

its simple to check , go for the below code:

 

if (source.u_dns_name && source.u_dns_name.indexOf('-sd-') != -1) {
    ignore = false;
} else {
    ignore = true;
}

 

I hope it helps you...  🙂

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

4 REPLIES 4

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Abhilasha G T ,

 

its simple to check , go for the below code:

 

if (source.u_dns_name && source.u_dns_name.indexOf('-sd-') != -1) {
    ignore = false;
} else {
    ignore = true;
}

 

I hope it helps you...  🙂

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Kieran Anson
Kilo Patron

Hi Abhilasha,

It'll be due to an error in your syntax, you've used a period rather than underscore for the fieldname

source.u.dns_name.contains('-sd-')

source.u_dns_name.contains('-sd-')

 

However I'd consider future proofing your code by doing the following

var dnsName = source.getValue('u_dns_name');

if(dnsName.toLowerCase().indexOf('-sd-') == -1)
ignore = true;

 

just a diffrence of 12 seconds @Kieran Anson  lol hehehe


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

AnimeshP_96
Tera Guru

hey @Abhilasha G T 

 

have you tried the same script on field map script? if not try it or apply some logs and check if its entering into the loop

instead of contains you can try indexOf()/ substring() for ignoring those record with -sd-

 


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh