cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming multiple items in an array

AvaniAnand
New Contributor
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

SpiroTaleski
Valued Contributor

@AvaniAnand 

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.