Blank records created during transform map

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2022 07:59 PM
Hello Experts
I have research to avoid inserting a record into the target table if X field is empty in the source record.
For example, in the source record, there is a group ID field and several other fields. The group ID is the coalese field (it has the sys_id).
Whithin those I have two fields that I validate as follows:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if (source.u_field1_name.nil() && source.u_field2_name.nil()) {
ignore = true;
}
})(source, map, log, target);
The idea is that IF those two fields are empty, the record is NOT inserted into the TARGET table.
But, what actually happens is that the record is CREATED, just ALL the fields in the TARGET are empty for the matching criteria set in the script (all other records that do not match are created normally as expected).
See the screenshot:
I mean, even the Group ID ends up blank for the records that match the script criteria. What I really need is that those records are NOT inserted in the Target table.
I have not been able to accomplish this. Your help will be greatly appreciated.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2022 05:15 AM
Hello Nestor,
Could you please once check with below script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
try {
if (!source.getValue("u_field1_name") && !source.getValue("u_field2_name")) {
ignore = true;
}
}
catch (e) {
gs.error(e);
ignore = true;
}
})(source, map, log, target);
Please mark my respsone as helpful/correct, if it answer your question.
Thanks