Field length check in Transform script

SK41
Giga Guru

Hi,

I  have a requirement in transform map where  i  have to reject  the record or ignore that particular string field if the  value  in  that  string field exceeds the length  of the field. This data is  coming  through excel  into my  instance table.

Please help me in this regard asap.

Thanks in Advance!     

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi,

In the transform map, click on the source field whose length you wanted to check.

if(source.u_your_field.toString().length>7) {

ignore=true;

}

Note: you need to mention the right field name and length you wanted to check in the code.

Mark the comment as correct/helpful if it helps to solve the problem.

View solution in original post

15 REPLIES 15

asifnoor
Kilo Patron

Hi,

In the transform map, click on the source field whose length you wanted to check.

if(source.u_your_field.toString().length>7) {

ignore=true;

}

Note: you need to mention the right field name and length you wanted to check in the code.

Mark the comment as correct/helpful if it helps to solve the problem.

SK41
Giga Guru

Thanks all!

Hi,

Did you mistakenly mark other answer as correct?

As I see similar script was provided before from my end pretty well (first).

You can only mark 1 response as correct.

So please mark the appropriate response as correct.

Regards
Ankur

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

Hi,

The script that i marked worked for me. 

Other scripts were helpful too but the one i marked was exactly the one i wanted.

Thanks!

Hi,

One question here if you guys can assist  me, instead of hard-coding the max  length  value(like 18 , 32)  in the  above code  can i make  it cofigurable/dynamic (like picking the field length value from the table)?

Regards.