- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 12:01 AM
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!
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 12:49 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 02:52 AM
Hi,
You can create a system property and can put the length there.
Go to system properties, create new and there give the unique name for your field and mention the value under value field. select type as integer.
Then in your script, you can fetch the value like this.
var max_length = gs.getProperty("your_property_name");
if(source.u_your_field.toString().length>max_length) {
ignore=true;
}
Mark the comment as helpful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 03:29 AM
The script I provided does this for you. Rather than static code, it dynamically gets the source field value length
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 02:59 AM
if i have to do this for other fields too each having different lengths, do i need to create new system property for each field length check?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 03:07 AM
Yes, If the lengths vary.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 03:09 AM
or you can use a string field and separate each length by comma. Have them stored in 1 specific order.
Then in your script, you can fetch the values like this
var max_length = gs.getProperty("your_property_name").toString().split(",");
if(source.u_your_field.toString().length>max_length[0]) {
ignore=true;
}
NOTE: max_length[0] refers to 1st field length. Similalry if you wnat 4th field, then use max_length[3]
Mark the comments as helpful if it helps.