Import set transform map should not overwrite target field if source field value is '##' (in example)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2018 11:47 PM
Hi
I have an import process that uses an attached Excel-file as source. I can then replace that Excel-file to implement changes on demand. As of now "Copy empty fields" is enabled on the transform map, which is fine, but I now need to provide a means to bypass "copy empty fields" in some cases.
I had the idea that I could simply replace the empty field with a fixed code (ie '##') and then change the field map to a scripted field and do the following:
answer = (function transformEntry(source) {
// Add your code here
if(source.u_asset_tag == '##'){
ignore = true;
}
else{
return source.u_asset_tag;
}
})(source);
To my surprise this does not prevent the field from an update, as itøs if target.asset_tag is just passed null or an empty string resulting in the value "Undefined".
Some thoughts: How is the "target" dictionary affected for a record when "Copy empty fields" is NOT enabled. Is the attribute removed from the target table behind the scenes, to prevent the field from being overwritten with a blanc value?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2018 11:30 AM
Update:
I've fiddled around with this new approach, that could have some potential:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if(action == "update") {
for (var property in source){
var targetProperty = property.replace('u_','');
if (source[property] == '##'){
gs.log('DEBUG Source property ' + property + ' contains ' + source[property]);
gs.log('DEBUG Target property ' + targetProperty + ' contains ' + target[targetProperty]);
delete source[property];
//_.omit(source,property);
}
}
}
})(source, map, log, target);
The logs in the center of the code works as expected and only when the input has the ## in it.
The line "delete source[property];" does not work unfortunately. I wonder if the source input variable is read-only (as per the documentation the map input variable is read-only).