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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to updates a share...
Power Apps
Unanswered

How to updates a sharepoint choice (multiple selections) list column from Power Apps using Patch

(1) ShareShare
ReportReport
Posted on by 381
Hello. 
I Have to update some powerapps code to include a section about sensitive data. The power apps reads from a sharepoint list. 
 
I have created a new column within the a sharepoint list, it is a choice column called SensitiveData, it display choice is Checkboxes (Allow multiple selections)
The values of the choice column are : 
PHI
PII
SOX
None of the above
 
On my Form i have added a data card, with a gallery called Gallery1. Inside that Gallery, i have a checkbox called Checkbox4.  This shows all the values of the choice column and allows users to select one or more than once choice. 
 
I have the following code : , but the SensitiveData bit does not update. (as per my comment). The rest works fine. 
 
What am i doing wrong... 
 
Patch(
    'SharePointList',
    LookUp(
        'SharePointList',
        ID = gal_Workspaces.Selected.ID
    ),
    {Update: {Value: "Signed"}},
    {Value: {Value: "Yes"}},
    {Date: Now()},
    {SenstiveData: Gallery1.Selected.Checkbox4} //This is the bit that doesnt work. 
);
Set(
    varPopUp,
    false
);
Navigate(
    Confirmation,
    ScreenTransition.Cover
)
 
What am i doing wrong?.  Can someone help me update the sharepoint list to what ever options the users selects from the checkboxes. 4
 
Thanks 
I have the same question (0)
  • Suggested answer
    MS.Ragavendar Profile Picture
    4,977 Super User 2025 Season 2 on at
     
    Gallery1.Selected.Checkbox4 only returns one selected item (the one associated with the checkbox control), but your SensitiveData SharePoint column expects an array of records in this format: 
     
    [{Value: "PHI"}, {Value: "PII"}]
     
    Patch Formula
     
    Patch(
        'SharePointList',
        LookUp(
            'SharePointList',
            ID = gal_Workspaces.Selected.ID
        ),
        {
            Update: {Value: "Signed"},
            Value: {Value: "Yes"},
            Date: Now(),
            SensitiveData: 
                ForAll(
                    Filter(Gallery1.AllItems, Checkbox4.Value),
                    {Value: ThisRecord.Value}
                )
        }
    );
     
    🏷️ Please tag me @MS.Ragavendar if you still have any queries related to the solution or issue persists.
    ✅ Please click Accept as solution if my post helped you solve your issue and help others who will face the similar issue in future.
    ❤️ Please consider giving it a Like, If the approach was useful in other ways.
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    The Patch would be - assuming here that the Items of the Gallery is Choices('SharePointList'.SensitiveData)
    {
       SenstiveData:
       ForAll(
          Filter(
             Gallery1.AllItems, 
             Checkbox4.Value
          ) As _Data,
          {Value: _Data.Value}
       )
    }
    Is this for new records only -  the values in the Gallery checkboxes for existing records requires a bit more thought here. Assuming you are using classic checkboxes, the Default of the CheckBox should be
    ThisItem.Value in 
    LookUp(
       'SharePointList',
       ID = gal_Workspaces.Selected.ID
    ).SensitiveData.Value
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • Vstar19 Profile Picture
    381 on at
    both the above formulaes save without error - but they are not updating the Sharepoint list with the checkboxes i selected.  The Sensitive Data column in sharepoint remains blank after i press the button (i have refreshed the sharepoint page)
     
  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    This one comes into the category of "should work but does not" - the reason I am guessing being that galleries were never designed to be inside Data Cards inside Forms and although you can manage to insert one with a bit of effort, anything outside the data card simply cannot properly reference the contents of the gallery - the result in my testing was that the filter when run from outside the form returned no records (therefore wrote nothing back).
    I have a workaround that seems to work - OnSelect of the CheckBox
    ClearCollect(
       colSelected,
       Filter(
          Gallery1.AllItems,
          Checkbox4.Value
       )
    )
    This however is going to cause issues with existing records as the collection will not contain those values initially - so your Patch
    With(
       {
          _Record:
          LookUp(
             'SharePointList',
             ID = gal_Workspaces.Selected.ID
          )
       },
       Patch(
          'SharePointList',
          _Record,
          {
             Update: {Value: "Signed"},
             Value: {Value: "Yes"},
             Date: Now(),
             SensitiveData: 
             If(
                IsEmpty(colSelected),
                _Record.SensitiveData,
                ForAll(
                   colSelected As _Data,
                   {Value: _Data.Value}
                )
             )
          }
       )
    );
    Clear(colSelected)
    
    It would also be a good idea to clear the colleciton whenever you select a new record.
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • Vstar19 Profile Picture
    381 on at
    Thanks Warren. 
    This appears to be now working. 
     
    How do i clear the selection?. the checkbox always go back to what ever was previously selected. 
     
    Once i hit save, i would like to clear the values?
     
     
  • MS.Ragavendar Profile Picture
    4,977 Super User 2025 Season 2 on at

    After the Patch, reset the control that holds the selections

    Reset(urcontrolname);

    If using checkboxes bound to a collection

    Clear(collectionName);

     

     

    🏷️ Please tag me @MS.Ragavendar if you still have any queries related to the solution or issue persists.
    ✅ Please click Accept as solution if my post helped you solve your issue and help others who will face the similar issue in future.
    ❤️ Please consider giving it a Like, If the approach was useful in other ways.
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    This depends if you are on an existing or new record. On existing records, the values are designed to remain as you have just updated the record and the Default of the checkbox
    ThisItem.Value in 
    LookUp(
       'SharePointList',
       ID = gal_Workspaces.Selected.ID
    ).SensitiveData.Value
    will then read that record and the checkboxes will show the value you just patched. Resetting the check boxes will not alter this (as they will simply read the record values again).
    For new records, you have an issue as  controls in a gallery cannot be reset from outside the gallery, so 
    Reset(CheckBox4)
    is not going to work (you may also get an error on this). You need to set the Reset property of the check box to a Variable (I have used varReset ) and then toggle the Variable (put this at the end of your patch code)
    UpdateContext({varReset: true});
    UpdateContext({varReset: false});
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • Vstar19 Profile Picture
    381 on at
    Brillant Thank You. 
     
     
    One Final thing. 
     
    So i have 4 check box values
     
    1. PHI, 
    2. PHII, 
    3. SOX
    4. Non-Sensitive
     
    If a user selects Non-Sensitive... How can i disable the other options?, i.e. if they select Non-Sensitive, they should not be able to select PHI, PII or SOX. 
    Additionally, if they select PHI or PHII or SOX, they should not be able to select Non-Sensitive. 
     
    Thanks 
  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    Firstly, I believe your original post has been solved, so please mark that accordingly.  Your next requirement for this rather unusual setup again needs a different approach - this should work in the DisplayMode of the checkbox
    If(
       CountRows(colSelected) > 0 && 
       (
          (
             CountRows(
                Filter(
                   colSelected,
                   Value = "Non-Sensitive"
                )
             ) > 0 && 
             ThisItem.Value <> "Non-Sensitive"
          ) || 
          (
             CountRows(
                Filter(
                   colSelected,
                   Value <> "Non-Sensitive"
                )
             ) > 0 && 
             ThisItem.Value = "Non-Sensitive"
          )
       ),
       DisplayMode.Disabled,
       DisplayMode.Edit
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • Vstar19 Profile Picture
    381 on at
    Hello Warren, 
     
    Sorry to be a pain. 
    So the Checkbox values should always be what is stored in sharpoint.. 
    For e.g. if The values are PHII, SOX in sharepoint, then PHII and SOX should always be pre-selected. 
     
    At the moment, the values are not pre-selected.. Do you know how to get that to work?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard