Rubick
Rubick

Reputation: 309

PowerApps Patch Sharepoint lists with Lookup fields throws errors when patching multiple lookupfields

Problem:

I am trying to use the Patch function in PowerApps to update a SharePoint list named City. The City list contains a lookup column Country referring to the ID, which has additional fields Language and Title marked in its definition. However, I am encountering the following error messages:

Version 1:

"The field 'Country_x003a__x0020_Title' is required."

Version 2:

"Error in 'City': Invalid data was used to update the list item. The field you are trying to update may be read-only."

Lists:

Code:

Here is the code I tried:

Version 1

Patch(
    City;
    Defaults(City);
    {
        Country: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
            Id: CurrentItem.ID;
            Value: CurrentItem.ID;
            'Country_x003a__x0020_Title': CurrentItem.Title; // Correct internal name
            'Country_x003a__x0020_Language': CurrentItem.Language // Correct internal name
        };
    }
)

Version 2

Patch(
    City;
    Defaults(City);
    {
        Country: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
            Id: CurrentItem.ID;
            Value: CurrentItem.ID;
        };

        Country_x003a__x0020_Title: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
            Id: CurrentItem.ID;
            Value: CurrentItem.ID;
        };
    }
)

Details:

Question:

How can I resolve this error and successfully patch the Country lookup column with the required fields in PowerApps?

Upvotes: 0

Views: 39

Answers (0)

Related Questions