I have an app and I am connected to a Sharepoint list as the datasource. There are many columns, so I split the columns across multiple forms in my app. All of the forms are on one screen. I have created a tabbed view and depending on the tab selected, only the corresponding form is visible. Now, again, only certain columns are shown on the different forms. The Item property of the forms is pointing to a record variable that I have filled with either the defaults from my list (in the case that I want to create a new record) or the selected item from a gallery which shows only summary information about the items in my Sharepoint list (in the case where I want to view/update an existing record).
In any case, whenever I open the app, select an item in the gallery, edit a field and then submit the change back to my list, it works the very first time. However, if I try to submit any subsequent changes, it results in the error mentioned in the post header.
Here is my patch code which is connected to the OnSelect action of a button on the screen:
UpdateContext({
varFormData:
Patch(
varFormData
, formPO_HdrInfo.Updates
, formPO_PrjInfo.Updates
, formPO_VendorInfo.Updates
, formPO_AdditionalInfo.Updates
, formPO_Attachments.Updates
)
});
Switch(
varFormMode
, 1
, Set(lookupRecord, Defaults('Purchase Orders'));
If(
IsError(
Patch(
'Purchase Orders'
, lookupRecord
, varFormData
)
)
, Notify(First(Errors('Purchase Orders', lookupRecord)).Error & ": " & First(Errors('Purchase Orders', lookupRecord)).Message, NotificationType.Error)
, Notify("Purchase Order created successfully!", NotificationType.Information)
)
, 2
, Set(lookupRecord, LookUp('Purchase Orders', ID=varFormData.ID));
If(
IsError(
Patch(
'Purchase Orders'
, lookupRecord
, varFormData
)
)
, Notify(First(Errors('Purchase Orders', lookupRecord)).Error & ": " & First(Errors('Purchase Orders', lookupRecord)).Message, NotificationType.Error)
, Notify("Purchase Order successfully updated!", NotificationType.Information)
)
// Should never happen as Submit button will not be visible in other modes
, Notify("Cannot submit updates in this mode", NotificationType.Error)
);
In my switch, varFormMode of 1 indicates a new record to be created on the Sharepoint list and a value of 2 means that this is an existing record to be updated.
Keep in mind that I do not have any of those read-only Sharepoint fields on any of my forms, so those columns should not exist in my varFormData record variable.
I have no idea why this error is happening and no idea on how to fix it. Your help is much appreciated