- 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-10-2020 12:14 AM
Hi,
You can do this in a transform script by getting the element descriptor.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var field = target.account_code.getED();
var max_length = field.getLength();
if(source.u_account_code > max_length){
ignore = true;
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 12:17 AM
Hi,
Thanks for your input.
I am new to this...can you please let me know what is element descriptor here.
Also,can i use this script in onBefore?
Regards.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 12:22 AM
Hi,
Yes this would go into an onBefore script. GlideElementDescriptor - This API allows you to access information about the field in question. The API shows the various information you can gather.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2020 12:41 AM
Hi,
you can use onBefore transform script to handle this
Is this for incoming field value then use this in onBefore transform script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var value = source.u_field;
var maxLength = 32;
if(value.length > maxLength){
ignore = true;
}
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader