I have a SharePoint list called ‘CustomerList’ with a form.
The ‘Add/ Update Customer’ button should insert a record if the ID is blank (ex the user selected ‘+New’ in the CustomerList
If a user selected a record from the list, the form should update the record when the user clicks the button.
PowerApps displays an error message for my Set statement ‘LookUp might not work correctly on large data sets’ I am unsure why because the form opened for a SINGLE RECORD not multiple records.
In my If statement, it states ‘varLookUpRecord’ not recognized because it does not like the Set statement.
I checked many many examples online but they did not apply because they were overwhelmingly galleries which has different properties (The gallery has an ‘OnSelect’ option (which the form does not) and the user can type Set(varRecord, ThisItem) ) or the examples online used multiple buttons (ex one for Insert the other for Update). I am using a form with a single button for insert and update.
Does anyone have any suggestions to resolve this issue? Thanks in advance for any suggestions.
This is my code for button’s ‘OnSelect’ option:
// Get current item's id
Set(varLookUpRecord, LookUp(CustomerList, DataCardValue6.Text))
// if ID is blank
If (IsBlank(varLookUpRecord),
// insert the record
Patch(CustomerList,
Default(CustomerList),
{Name: DataCardValue2.Text,
State: DataCardValue3.Text,
'Favorite Sport': DataCardValue4.Selected }),
// else update record
Patch(CustomerList,
ThisItem,
{Name: DataCardValue2.Text,
State: DataCardValue3.Text,
'Favorite Sport': DataCardValue4.Selected }),
) // end if