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 / Update function with C...
Power Apps
Unanswered

Update function with Checkboxes in a Gallery

(0) ShareShare
ReportReport
Posted on by 6

Hi There 🙂

 

Can you please help me with my problem?

 

I have a gallery with Checkbox for each item

 

I have a button with this formula to update records in DB

If(Checkbox.Value=true;UpdateIf(MainVega;EstDateIn=EstDateIn_Label.Text; {Real_x0020_DateIN:NowLabel.Text}))
 
The problem is that  if I check only one checkbox, it update desired cell for all items and not only for checked item.
 
Thank you in advance!
 
 
Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @Jivko_Ralchev

    I am thinking that you will need to start by making a Collection.  Put this code in the OnVisible property of your screen.  Notice how we are adding a new column to track which rows should be changed in the datasource.

    ClearCollect(
     yourCollection;
     AddColumns(
     your_datasource_name;
     "changeDate";
     false
     )
    )

     

    Then make the collection the source for the gallery by placing it in the Items property.

    yourCollection

     

    Insert your checkbox into the gallery and put this code in the OnCheck property

    Patch(myCollection; ThisItem; {changeDate: true})

     

    Similar code must go in the OnUncheck property

    Patch(myCollection; ThisItem; {changeDate: false})

     

    Now create a new label to hold the date and put this code in the onChange property.  Make sure the column name Real_x0020_Date exists in your collection and change the name if needed.

    Patch(myCollection; ThisItem; {Real_x0020_Date: NowLabel.Text})

     

    At this point you will have a collection with all of the information needed to update the datasource.  Put this code in the OnSelect property of your button.

     

    ForAll(
     Filter(myCollection, changeDate=true);
     Patch(
     MainVega;
     ID=myCollection[@ID];
     {Real_x0020_Date: myCollection[@Real_x0020_Date]}
     )
    )

     

    Hopefully this idea will work!

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Jivko_Ralchev Profile Picture
    6 on at

    HI @mdevaney 

     

    on Label I don't have onChange property, instead that I used onSelect property. Is that correct?


    then on my submit button I put the below formula, but there are two errors. 

    "ForAll" and "Patch" functions have invalid arguments

    ForAll(
     Filter(Collection; changeDate=true);
     Patch(
     MainVega;
     ID=Collection[@ID];
     {Real_x0020_DateIN: Collection[@Real_x0020_DateIN]}
     )
    )

     

    Where do I mistake?

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Jivko_Ralchev 

    I should have said Text Input instead of Label.  A Text Input has an OnChange property wheras a Label does not.  I will make that correction above.

     

    Can you please send a screenshot of the error message along with the forumla underlined in red where the error is occurring?

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Jivko_Ralchev Profile Picture
    6 on at

    Hi @mdevaney ,

     

    I replaced Label with Text input. Yes there is onChange property 🙂

     

    Here  is a screenshot of the error messages and the formula.

    Messages are on Bulgarian, but they actually means that  "ForAll" and  "Patch" functions have invalid arguments. 

     

    Error.png

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Jivko_Ralchev 

    Can you verify the column name is correct?

     

    If they are, I feel like maybe this...

    {Real_x0020_DateIN: Collection[@Real_x0020_DateIN]}

     

    Might need to be rewritten like this

    {Real_x0020_DateIN: Collection[@Real DateIN]}

     

    (I try to stay away from spaces in my SharePoint column names as they sometimes cause confusion. But that's just me!)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard