- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 01:03 PM
Hey all,
I'm working on a project, in Tokyo, where I need to update a set of records that are being brought in by a CSV import file utilizing a Transition Map. So, I'm expecting to setup a Transition Map Script to try and do the following, but having a bit of trouble coming up with the best way to do this...
If the asset name is equal to a current asset name in the hardware asset table, then I ONLY want to update the fields that are NOT blank on the import table. Example:
* Asset Name: Hardware1
* IP Address: 100.100.100.100
* Location:
* Asset Type:
* DNS Name: Hardware
So, I only want to update the Asset Name, IP Address and DNS Name on this particular record. I need to ignore Location and Asset Type as they are blank.
Then I need to perform this action for every record on the import file. (I'm guessing a FOR statement somehow?)
So, the issue I'm having is how exactly to script "updating" each record that has information but "skipping/ignoring" each record that is blank. I'm guessing I can use a getElements() to get the array of what the fields are holding, but I don't know the best way to either save/update or ignore/skip the proper fields. 😕
Thoughts? Ideas?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 02:03 PM
Hi, I would not expect existing field content to be overwritten by a blank\empty value during update, unless the transform map 'Copy empty fields' == true, so setting this field to false/removing the tick should resolve this requirement.
If you are coalescing on the Asset Name, then in your transform script you can simply set some conditions when the action is update. Untested but something like
if(action == 'update') {
target.field1 = 'someHardCodedValue';
target.field2 = 'someOtherHardCodedValue';
//mapping a reference field
var recCheck = new GlideRecord('theReferncneTable');
if(recCheck.get('fieldReferencedInImportFile', source.importfFeldName)) {
target.fieldX = recCheck.sys_id;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 02:03 PM
Hi, I would not expect existing field content to be overwritten by a blank\empty value during update, unless the transform map 'Copy empty fields' == true, so setting this field to false/removing the tick should resolve this requirement.
If you are coalescing on the Asset Name, then in your transform script you can simply set some conditions when the action is update. Untested but something like
if(action == 'update') {
target.field1 = 'someHardCodedValue';
target.field2 = 'someOtherHardCodedValue';
//mapping a reference field
var recCheck = new GlideRecord('theReferncneTable');
if(recCheck.get('fieldReferencedInImportFile', source.importfFeldName)) {
target.fieldX = recCheck.sys_id;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 05:16 AM
Tony,
Good point, I did forget about that. However, how about if the information is the same in both the import table and the target table? Should I just let it update it and it will be fine? I guess my point is, I forgot to mention that they only wanted fields updated that have "changed".
Again, thank you for the info. I will look into this. 🙂
Take care