web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Cannot patch multi-sel...
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);
);
Categories:
I have the same question (0)
  • abc 123 Profile Picture
    789 Moderator on at
    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), ...
     
  • CG-07102153-0 Profile Picture
    23 on at
    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);

    );
  • Verified answer
    CG-07102153-0 Profile Picture
    23 on at
    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,
    ...
    }
    );

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

#2
11manish Profile Picture

11manish 224

#3
Valantis Profile Picture

Valantis 181

Last 30 days Overall leaderboard