@mdevaney
I got it to work with the defaultvalue and patch functions. Thanks for your help!
For my Default for the input field I used:
LookUp( SelectedItem; ItemId = PRODUCTNUMBER; Qty ) //Identify the row and return its current Qty from the collection
And for the OnChange for the input field:
Patch(SelectedItem;{ItemId: ThisItem.PRODUCTNUMBER}; {ItemId: ThisItem.PRODUCTNUMBER; ItemName: ThisItem.PRODUCTNAME; Qty:Qty.Text})
//Return the record in the collction by ItemId and update it, otherwise it will be created
I tried using ThisItem as the second argument as your example suggested, but that gave the error that the function Patch had invalid arguments. I suspect this to be because ThisItem had more columns in it than my collection did. As my datasource wasn't the same as the source I was patching to, I had to specify the record by Id.
Patch(
SelectedItem,
ThisItem,
{ItemId: ThisItem.PRODUCTNUMBER; ItemName: ThisItem.PRODUCTNAME; Qty:Qty.Text}
)
//Did not work for me
Simliarly setting
ThisItem.Qty
Didn't work either. I therefore had to find the record with the lookup function. But your post definately got me to the solution, thanks again!
TLDR: Patch function together with ThisItem only works if you are patching to the source the items are read from, or the column definitions match up. If you're patching to another source, specifiy the record by its unique Id (product number in my case).