I have an array which contains multiple objects, for examplelocal!cartItems: [ {id:22,name:abx,cost:10,qty:1}, {id:23,name:xyz,cost:15,qty:1}, {id:24,name:jkl,cost:18,qty:1}, {id:25,name:test ,cost:50,qty:1}]
now I want to get the object whose id is 24 in this array and then change this object's data like(change qty to 2 and cost to 36) and save back to same array(local!cartItems).
Discussion posts and replies are publicly visible
In Appian, local variables are immutable. Taking aside that in interfaces you can modify variable in a saveInto. But in general, you can use lookup() or wherecontains() to find items in a list, index() or "[]" to fetch that item and updatearray() to create a new array with modified data.
Thanks for your response!
But how to find any item by key-value like how can I get item or index of the item whose id is 24. lookup() and wherecontains() are for indexed arrays but I don't understand how to match the key-value and get the index of the item.
Try lookup(local!cartItems.id, 24)
Thanks Stefan!