Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Cannot patch multi-select Choice fields - form saves only 1 record to List

(1) ShareShare
ReportReport
Posted on by 23

I'm using a patch function on a PowerApps form to update specific (Dropdown_ProjectName.Selected) project records in an underlying list.

The patch works great for the 'Budget percentage' field (TextInput), but I'm having trouble patching two multi-select Choice columns: 'Team composition', which is a Person field (containing DisplayName, ...), and 'Countries'.

When I use .SelectedItems as for the Team composition column, the form saves only 1 item, and not any others that have been selected.

The ForAll() formula I use for the Countries column - which appears to be a solution proposed elsewhere on this forum - produces multiple errors for me, so I might be using it wrong.
How an I fix this?

Patch('Project database', Dropdown_ProjectName.Selected, {   
        'Team composition': DataCardValue_TeamMembers.SelectedItems,
        'Countries': ForAll(DataCardValue_Countries.SelectedItems As aCountry, {Value: aCountry.Value}),
        'Budget percentage': Value(DataCardValue_BudgetPercentage.Text)/100
});
EDIT 1 (Additional Information):
In case it helps, the DefaultSelectedItems  property of the Countries multi-select field is populated with existing items from the selected project, like so:
LookUp('Project database', 'Project name' = Dropdown_ProjectName.Selected.'Project name', 'Primary beneficiary (country / countries)').Value
Similarly, for Team members it's like this:
LookUp('Project database', 'Project name' = Dropdown_ProjectName.Selected.'Project name', 'Team member(s)').DisplayName
 
The Update property of the DataCard_Countries is set to DataCardValue_Countries.SelectedItems, the Update property of the DataCard_TeamMembers is set to DataCardValue_TeamMembers.SelectedItems
 
EDIT 2:
I have further experimented and found that the code below works ONLY when first editing a project, i.e. adding team members or countries (although it produces an error notification based on the code below, but the list updates correctly). However, it produces a server error when trying to edit the selected project again (such as removing 1 out of 3 team members, or adding 1 additional country to the existing 2).
 
 
Patch('Project database', Dropdown_ProjectName.Selected, {
'Team composition': ForAll(DataCardValue_TeamMembers.SelectedItems, {
Claims: "i:0#.f|membership|" & ThisRecord.Email,
Department: ThisRecord.Department,
DisplayName: ThisRecord.DisplayName,
Email: ThisRecord.Email,
JobTitle: ThisRecord.JobTitle,
Picture: ThisRecord.Picture
}),
'Countries': ForAll(DataCardValue_Countries.SelectedItems, {
Id: ThisRecord.Id,
Value: ThisRecord.Value
}),
'Budget percentage': Value(DataCardValue_BudgetPercentage.Text)/100
});
 
If(
// check if there were any errors when the test score was submitted
!IsEmpty(Errors('Project database')),
// if true, show any error message
Notify(
Concat(Errors('Project database'), Column&": "&Message),
NotificationType.Error
),
// else, reset form fields and how success message
Notify("Record successfully updated.", NotificationType.Success);
Reset(Dropdown_ProjectName);
);
  • Verified answer
    CG-07102153-0 Profile Picture
    23 on at
    Cannot patch multi-select Choice fields - form saves only 1 record to List
    I have found the solution. The issue was with the DefaultSelectedItems  properties of the 'Countries' and 'Team composition' fields which were defined as:
     
    LookUp('Project database', 'Project name' = Dropdown_ProjectName.Selected.'Project name', 'Countries').Value
     
    LookUp('Project database', 'Project name' = Dropdown_ProjectName.Selected.'Project name', 'Team composition').DisplayName
     
    This returned the wrong data type. Removing '.Value' and '.DisplayName' fixed the issue and allowed me to implement the patch simply like this:
     
    Patch(
    'Project database',
    LookUp(
    'Project database',
    'Project name' = Dropdown_ProjectName.Selected.'Project name'
    ),
    {
    'Team composition': DataCardValue_TeamMembers.SelectedItems,
    'Countries': DataCardValue_Countries.SelectedItems,
    ...
    }
    );
  • CG-07102153-0 Profile Picture
    23 on at
    Cannot patch multi-select Choice fields - form saves only 1 record to List
    Thank you for this suggestion, @abc_123.
     
    I'm looking to update an existing row, and there doesn't seem to be an issue with this in my patch statement by using Dropdown_ProjectName.Selected, because the correct row is being updated (a) every time I patch the TextInput field ('Budget percentage'), and (b) whenever the 'Team_composition' and 'Countries' fields are still empty in the underlying list and I patch them for the first time.

    UPDATE:
    I changed how the patch function identifies the specific record to be updated, but I still get an error message saying "Network error when using Patch function: The requested operation is invalid."

    What am I doing wrong?
    Updated code below:

    Patch(
    'Project database',
    LookUp('Project database', 'Project name' = Dropdown_ProjectName.Selected.'Project name'),
    {
    'Team_composition': ForAll(DataCardValue_TeamMembers.SelectedItems,
    {
    Claims: "i:0#.f|membership|" & ThisRecord.Email,
    Department: ThisRecord.Department,
    DisplayName: ThisRecord.DisplayName,
    Email: ThisRecord.Email,
    JobTitle: ThisRecord.JobTitle,
    Picture: ThisRecord.Picture
    }),
    'Countries': ForAll(
    DataCardValue_Countries.SelectedItems,
    {
    Id: ThisRecord.Id,
    Value: ThisRecord.Value
    }
    ),
    'Budget_percentage': Value(DataCardValue_BudgetPercentage.Text) / 100
    }
    );

    If(
    // check if there were any errors when the test score was submitted
    !IsEmpty(Errors('Project database')),
    // if true, show any error message
    Notify(
    Concat(
    Errors('Project database'),
    "Column: " & Column & ", Message: " & Message
    ),
    NotificationType.Error
    ),
    // else, reset form fields and how success message
    Notify(
    "Record successfully updated.",
    NotificationType.Success
    );
    Reset(Dropdown_ProjectName);

    );
  • abc 123 Profile Picture
    784 Super User 2025 Season 1 on at
    Cannot patch multi-select Choice fields - form saves only 1 record to List
    Your Patch() function syntax seems incorrect.
       Patch('Project database', Dropdown_ProjectName.Selected, ...
     
     
    Adding a new item:
       Patch( Customers, Defaults( Customers ), { CustomerName: "Contoso" } )
     
    Updating an existing Item
       Patch( Customers, Filter( Customers, CustomerName = "Contoso" ), { Phone: "1-212-555-1234" } )
     
    I would expect it to be either:
       Patch('Project database', Defaults('Project database'), ...
    or
       Patch('Project database', Filter('Project database', SomeFieldofMine.Value = Dropdown_ProjectName.Selected.Value), ...
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,618 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,948 Most Valuable Professional

Leaderboard