
Hi,
Im trying to build an editable table similar to this
https://matthewdevaney.com/power-apps-excel-style-editable-table-part-1/
However im stuck on building a save button that looks for all the items in a gallery and patches the collection of items if the toggle has changed.
The code i was given in the tutorial was this, it differs from mine by i dont wish to upload to sharepoint collection i just want to update the current collection and i just cant get the code right, see my code below
ForAll(
Filter(
gal_EditableTable.AllItems,
tog_isChanged.Value
) As ChangedRows,
Patch(colUpdates,
Defaults(colUpdates), {
ID: ChangedRows.ID,
ItemNumber: ChangedRows.txt_ItemNumber.Text,
Description: ChangedRows.txt_Description.Text,
Quantity: Value(ChangedRows.txt_Quantity.Text),
Location: ChangedRows.txt_Location.Text
})
);
// Update SharePoint with new values
Patch('Inventory Count', colUpdates);
Clear(colUpdates);
// Return gallery to view mode
Set(varGalleryMode, Blank());
IGNORE ITS THE CODE BELOW
ForAll(
Filter(
Gallery.AllItems,
tog_isChanged.Value
) As ChangedRows,
Patch(colDATA,ChangedRows,
{
GID:GID,
Sample: ChangedRows.GalSampleID_1.Text,
FROM: ChangedRows.GalFromM_1.Text,
TO: ChangedRows.GalToM_1.Text,
}
)
);
I know im on the right track..
Thing is...you're ForAll is the key to this. Instead of looking at it as a For/Loop, use it as it was designed...to return a Table.
You mention that didn't want to "upload to SharePoint collection"... I'm not sure what you mean by that, but you were certainly attempting to update your Inventory Count list in that formula.
Please consider changing your Formula to the following:
// Update SharePoint with new values
Collect('Inventory Count',
ForAll(Filter(gal_EditableTable.AllItems, tog_isChanged.Value) As _item,
{
ID: _item.ID
ItemNumber: _item.txt_ItemNumber.Text,
Description: _item.txt_Description.Text,
Quantity: Value(_item.txt_Quantity.Text),
Location: _item.txt_Location.Text
}
)
)
// Return gallery to view mode ??
Set(varGalleryMode, Blank());
In the above, we use the ForAll to return a Table of the records based on the Filter of the Gallery where the toggle is true. This creates a record table that we can just push back to the Collect function to the datasource. Collect will handle the rest - no collections needed.
I hope this is helpful for you.