Change The Values In A Record (Patch)

Input collection: myInventory33

IDName Quantity
1001Desktop PC10
1002Monitor23
1003Laptop16


Output collection: mySolution33a (update ‘Monitor’ quantity to 18)

IDName Quantity
1001Desktop PC10
1002Monitor18
1003Laptop16


Solution code:

//Create a collection
ClearCollect(myInventory33,
{ID:1001, Name: "Desktop PC", Quantity: 10},
{ID:1002, Name: "Monitor", Quantity: 23},
{ID:1003, Name: "Laptop", Quantity: 16}
);

//Change the value in a cell code
ClearCollect(mySolution33a,myInventory33);
Patch(mySolution33a,LookUp(mySolution33a,ID=1002),{Quantity: 18});


Output collection: mySolution33b (update multiple values for ID 1003)

IDName Quantity
1001Desktop PC10
1002Monitor23
1003Surface Laptop33


Solution code:

//Create a collection
ClearCollect(myInventory33,
{ID:1001, Name: "Desktop PC", Quantity: 10},
{ID:1002, Name: "Monitor", Quantity: 23},
{ID:1003, Name: "Laptop", Quantity: 16}
);

//Change multiple values in a row code
ClearCollect(mySolution33b,myInventory33);
Patch(
    mySolution33b,
    LookUp(mySolution33b,ID=1003),
    {Name: "Surface Laptop", Quantity: 33}
)