- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2020 04:32 PM
a seemingly basic question, but has defeated me so far
Importing data (from CSV) and transforming to the UNIX Server table
I have fields in the imported data that map to 2 choice fields, one string field and one reference field in the target
For these four fields only - when the source is empty / null I need the target field to be set to null. Any other source fields that are null are not to overwrite the target
I cannot work out how to only do this for some fields
- Setting the Copy Empty Fields [copy_empty_fields] field to True on the transform map - sets it for all fields and I cannot get it to ignore some
- when Leaving the Copy Empty Fields [copy_empty_fields] field to False on the transform map - cannot get it to set a null value on the target record when using a sys_transform_entry with a script for the fields in question
I assume I can do this with an onAfter script, but was trying to avoid that
Any thoughts on how to proceed?
thanks,
Steve
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2020 04:46 PM
Did you try right in the Script field of the Table Transform Map itself:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2020 11:33 PM
Hi,
Please refer below link, this might help you,
If my answer helped you, please mark answer as helpful and correct.
Thanks and regards,
Megha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2020 03:31 PM
thanks to everyone who responded. I deployed
//setting fields that need to be null if the source sends null
//https://community.servicenow.com/community?id=community_question&sys_id=2124bdbcdbc018d8f7fca851ca9619ff - thx Jim
if (source.u_patching_sequence.nil()){
target.u_patching_sequence = '';
}
if (source.u_patching_category.nil()) {
target.u_patching_category = '';
}
if (source.u_patching_task.nil()) {
target.u_patching_task_description = '';
}
if (source.u_primary_app_group.nil()) {
target.assignment_group = '';
}
if (source.u_patching_window.nil()) {
target.maintenance_schedule = '';
}
left the field map entries in place for the same fields so they are populated when the source provides a value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 07:35 PM
Hi,
Did you end up also marking the "Copy empty fields" checkbox as mentioned by Jim?
Because having the script and the checkbox marked seems to defeat the purpose of the checkbox which is actually does what your script is doing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 08:04 PM
regards,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 08:43 PM
Great! That is what I thought.
Having the script with only the fields we want should do the trick and of course the checkbox should be off.
Cheers,
Jefferson