Renaming multiple items in an array
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 05:45 PM
I have a question regarding renaming multiple items within an array. Currently, I'm using the following mapping to rename one item:
```
map(x => x.mapKeys((value, key) => key.contains('Memo') ? "description" : key))
```
However, I'm encountering difficulties when attempting to rename another item within the same array ("unique id" to "custcol_xero_unique_key"). I've tried various approaches but keep running into compilation errors.
Would you have any suggestions on how to incorporate the renaming of this second array item into the existing formula?
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 06:28 AM
If you want to add another mapping rule, you can do that withnin the existing mapKeys function:
map(x => x.mapKeys((value, key) => key.contains('Memo') ? "description" : (key.contains('unique_id') ? "custcol_xero_unique_key" : key)))
Or, if you need to add conditions for more fields than also you can utilize the match operator.
