Transform Map - Ignore Row if any fields are empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 04:03 AM
Hello All,
When transforming an import set table. Is it possible to ignore any rows that have an empty field?
We want to ensure that all rows to be imported have complete information. Is there a transform script I can utilize to achieve this?
I have tried just using 'Enforce Mandatory Fields' but this doesn't work, the data is still imported with empty fields.
Many Thanks
Harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 05:45 AM
Hi Harry,
Can you check this wiki link it mentions that if we use ignore=true in onStart then the entire transformation will be stopped and no further processing will occur.
http://wiki.servicenow.com/index.php?title=Transform_Map_Scripts#gsc.tab=0
Can you try adding some logs and check in error logs?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 05:50 AM
I have had a read through that and one thing I have noted i this under onStart:
When: The onStart event script is processed at the start of an import run, before any data rows are read.
I think the problem here is that the data is not being read.
If i change it to onBefore and add error=true, it will import any rows that have all data populated and stop the transform when it comes across a row with missing data......so the code is ok and the data is being read when using onBefore.
May need to look at this a different way and delete any created records if an error occurs. Not sure how I would go about that though.
I cant see any events that will validate all of the data before starting the transform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 02:44 PM
Hi Harry,
onStart transform script will not consider source.u_field1, rather you'll have to query (gliderecord) the import set table and apply the appropriate checks.
Hope this helps.
Best regards,
Harshit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2025 03:32 AM
Yes, Harry. You can right the code like this:
if(source.u_field1 == '' || source.u_field2 == '' || source.u_field3 == '')
{
error = true;
}
Source for this information is inside this link : https://www.servicenow.com/docs/bundle/xanadu-integrate-applications/page/script/server-scripting/re...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 06:12 AM
yes it will need to be an OnBefore so each row is checked but set error to true.
error = true
and this will halt the entire transformation, unfortunately it won't delete or rollback any previously updated or created records...
Transform Map Scripts - ServiceNow Wiki
error | Boolean Flag | When set to true, will halt the entire transformation for the current import set, with an error message. |
error_message | String | Defines a custom message to be sent in the <error_message> XML response. |
the only other option I can think of right now to give you an early heads up would be to put a check on the staging table so that the fields are checked there in your onStart transform