
I know the issue (see end), but do not know how to solve or the best workaround.
I will try to provide as much information as possible. (I was following this tutorial "Editable Grid in Power Apps" by Reza Dorrani)
Canvas App Interface
It is connected to SharePoint List for data source.
High Level Data Design
If I follow the steps below, it gives me an error (error message in Title):
- Edit in Grid View
- Add a New Item (which add the item to 'GridDataCol')
//OnSelect of New Item
Set(
varNumber,
varNumber + 1
);
Collect(
DataGridCol,
Patch(
varNewRecord,
{
ID: varNumber
}
)
);
- Delete (click trash icon - see image above) the newly created item without saving to collection/source first (which add the item to 'DeleteCol')
// OnSelect of Trash icon, If the item exists in DataGrid Col add item to Delete collection and then remove
If(
CountRows(
Filter(
DataGridCol,
ID = ThisItem.ID
)
) > 0,
Collect(
DeleteCol,
ThisItem
);
Remove(
DataGridCol,
ThisItem
)
);
- SaveChanges/Exit Grid View (tries to remove the new item, present in 'DeleteCol', from the source - SharePoint List)
// OnSelect of Exit/Save button
Patch(
'Data',
UpdateIf(
DataGridCol,
Created = Blank(),
{ID: Blank()}
)
);
Remove(
'Data',
DeleteCol
);
Clear(DeleteCol);
Notify(
"Data Updated!",
NotificationType.Success,2000
);
However, technically, the item is not present in the SharePoint list, resulting in a popup error stating ' Network Error using remove function. Item not found ' I could verify if the item exists in the Data Source (SharePoint List) every time, but that would be resource-intensive.
Is there a more efficient workaround/fix?
Any help is appreciated, thanks.
Hi @Gurkirat_K,
You could leave the ID blank and filter out the empty IDs - which are rows created within the app that are not yet patched to the List. Alternatively, you could use other system columns (e.g. Created) to filter out the in-memory rows:
Remove(
'Data',
Filter(
DeleteCol,
Created <> Blank()
)
);
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!