cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iwonder
Impactful Individual
Impactful Individual

Update Gallery CheckBox

Thank you for taking the time to read my question.

 

I asked this one earlier and thought that I understood the answer but after a few days I'm still stumped.

 

What I have is a Gallery that has a checkbox and a label for each record.

 

Gallery.Items = Filter('[dbo].[MedicationActive]',MedicationFacility = SelectedFacility.Text Or MedicationFacility = "All", MedicationLine = SelectedLine.Text Or MedicationLine = "All").Medication

 

Gallery.TemplateFill = If(ThisItem.Medication in colPelMed.Med,LightBlue,Transparent)

 

Gallery.OnCheck = If(ThisItem.Medication = "NONE",RemoveIf(colPelMed,Facility=SelectedFacility.Text,Line=SelectedLine.Text,Med<>"NONE"),RemoveIf(colPelMed,Facility=SelectedFacility.Text,Line=SelectedLine.Text,Med="NONE"));//update the collection
Collect(colPelMed,{Facility:SelectedFacility.Text,Line:SelectedLine.Text,Med:ThisItem.Medication});//add the currently selected item to the collection

 

IMPORTANT: colPelMed holds more than one record. It holds records for other Facility/Line combinations so I can't ClearCollect this collection. I have an unknown number of Facility/Line combinations so I can't create a unique collection for every combination.

 

What I want to do is if "NONE" is selected, then I want to clear all the other check boxes. If any of the other checkboxes are selected, then "NONE" should be cleared. Also, if there is no record found in the colPelMed then "NONE" should be selected to start, otherwise check the correct checkboxes. The reason I need to do this is because the user can start a record but not complete it. They may need to switch to another Facility/Line, update that record a bit more, then come back. Therefore I need to set this gallery to where they left off. 

 

I have a second gallery I use to test with. It shows what's currently in colPelMed filtered for Facility and Line. When I use the RemoveIf() function I can see this gallery refresh correctly so I know that my OnCheck formula is ok. I have not written my OnUnCheck yet as I want to get the OnCheck to work first... baby steps.

 

Gallery.png

 

Any help would be great. I've been working on this for days.

 

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@iwonder 

Are you using the formula I provided on the Checkbox Default?

LookUp(colPelMed, 
       Med=Self.Text && 
       Facility=SelectedFacility.Text &&
       Line = SelectedLine.Text,
       true
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

iwonder
Impactful Individual
Impactful Individual

Was just getting there.

 

Here is what I had and your code:

//If(ThisItem.Medication in LookUp(colPelMed,And(Facility=SelectedFacility.Text,Line=SelectedLine.Text),Med),true,false);
LookUp(colPelMed, 
       Med=Self.Text && 
       Facility=SelectedFacility.Text &&
       Line = SelectedLine.Text,
       true
)

 

With your code, when I click on NONE it checks, then when I click on "Am", "NONE" remains checked. with my code, when checking "Am", "NONE" becomes unchecked.

 

I also noticed if I, for example, select items further to the right, say Mx, Pp, Pu... when I check NONE, the first one always becomes unchecked. In this case Mx becomes unchecked.

View solution in original post

20 REPLIES 20
yashag2255
Super User
Super User

Hi @iwonder 

 

To configure this, can you update the configuration to:

 

CheckBox -> Default -> If(ThisItem.Meditation in SelectedCheckboxes.Value,true,false)

 

OnCheck ->  If(ThisItem.Meditation = "None", ClearCollect(SelectedCheckboxes, {Value:ThisItem.Meditation}), Collect(SelectedCheckboxes,{Value:ThisItem.Meditation});RemoveIf(SelectedCheckboxes, Value = "None")

 

OnUncheck -> Remove(SelectedCheckboxes, ThisItem)

 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

iwonder
Impactful Individual
Impactful Individual

Hi @yashag2255 

 

Thank you very much for you quick reply.

 

I forgot to include the Gallery.Default info. This is what I have there:

 

If(ThisItem.Medication in LookUp(colPelMed,And(Facility=SelectedFacility.Text,Line=SelectedLine.Text),Med),true,false)

 

You gave me an idea though...

 

I could create a temp collection. I am thinking I could Filter() colPelMed to get the correct record, and then put that record into my temp collection. I could call it SelectedCheckboxes.

 

Then I could follow your instructions. I'm just not sure how to get the data from colPelMed into my new collection. Do I need to do a ForAll on Filter(colPelMed) to get the values into SelectedCheckboxes?

 

Thanks again

RandyHayes
Super User
Super User

@iwonder 

Didn't seem like you wanted to clear your collection each time as you stated the collection will have other information in it.

 

Consider the following:

 

OnCheck of the CheckBox:

With({medItems:
    Filter(colPelMed, 
        Facility=SelectedFacility.Text &&
        Line = SelectedLine.Text
    )
    },
    //Add med if not in list  
    If(!(ThisItem.Value in medItems.Med), Collect(colPelMed, {Med:ThisItem.Value}));
    //Remove all other meds if "None"
    If(Self.Text = "None", RemoveIf(colPelMed, Med<>"None" && Facility=SelectedFacility.Text &&
        Line = SelectedLine.Text));
    //Remove "None" if this is not "None"
    If(Self.Text<>"None", RemoveIf(colPelMed, Med="None" && Facility=SelectedFacility.Text &&
        Line = SelectedLine.Text)) 
)

 

OnUncheck of CheckBox:

RemoveIf(colPelMed, Med=Self.Text && Facility=SelectedFacility.Text &&
        Line = SelectedLine.Text)) 

 

Default of Checkbox

LookUp(colPelMed, 
       Med=Self.Text && 
       Facility=SelectedFacility.Text &&
       Line = SelectedLine.Text,
       true
)

 

TemplateFill of Gallery:

If(Checkbox1.Value, LightBlue, Transparent)

 

I am not sure what you are referring to with the TempCollection.  You really don't need any collections for this solution, but even if the one colPelMed, I am not sure there is any need for a second.  If you could expand on that, perhaps that would help understand more.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
iwonder
Impactful Individual
Impactful Individual

Hi @RandyHayes 

 

What I'm doing is....

 

I am creating an app to track manufacturing information in an app. The app is to be used at multiple facilities. Each facility has multiple lines. Users need to be able to flip between manufacturing lines. This means they enter a few data points (incomplete record) then flip to another line and enter a few data points (incomplete record) then flip back. This all uses the same screen, it just changes the filter for the gallery in which all this info is displayed. When they flip back I need to be able to populate the screen with the data so they can pick up where they left off. This is also why I use a gallery to display / edit this info. When I need to start a new record, I just add the Facility and Line info to the collection, then change screens and the gallery shows a new "blank" record.

 

To do this I save the data to a Collection that has Facility and Line plus the rest of the data points. I can do this because only one thing can be made per line at a time, so there will only ever be one active record for a facility/line at a time. Once the record is saved to my SQL DB, I will clear the record from the collection.

 

Doing it this way allows me to only have a few screens based on line type instead of making a screen for every facility/line combination.

 

On the screen where they enter/edit data I have a gallery which I set to the record in the collection limited by a filter based on Facility and Line. This means my gallery only ever has one record to show which is just what I want. This is all working great.

 

As a part of this record I need to save medicines used. There can be None, 1 or many per thing being manufactured. So I have put a sub gallery in my main gallery. This sub gallery is what my question is about. 

 

colPelMed also has Facility and Line in it so that I can store the values selected by the user for the current facility/line combination. Again, only one record can exist for the combination at a time. I need to save these like the main record because users can switch between Facility/Line combos and switch back.

 

At time of saving I plan to patch the main manufacturing record along with the med information (med info will be a comma separated string in a single field in my SQL table) into my SQL table.

 

I hope this is clear and explains why and how I use collections.

 

So I cannot ClearCollect colPelMed because it has other incomplete records in it. I can only clear the records that pertain to the current facility/line combination. So I thought that if the only way to uncheck all checkboxes if NONE is selected, or uncheck NONE if anything else is selected is to use ClearCollect, then I could take the proper record from colPelMed and put it into a second collection that only has the one record. Then I could ClearCollect. Then when the users saves or flips I could RemoveIf() the record from colPelMed and add the data from the second collection. If I don't have to do this, that would be great.

 

I'll try your suggestions now.

 

Thanks again both of you for your help.

Please let me know if you need any clarification.

iwonder
Impactful Individual
Impactful Individual

Hi @RandyHayes ,

 

I forgot to ask, in your OnCheck code... what is medItems?

 

Thanks again

RandyHayes
Super User
Super User

@iwonder 

First, Meditems is:

   Filter(colPelMed, 
        Facility=SelectedFacility.Text &&
        Line = SelectedLine.Text
    )

It is a With statement that uses that as a scoped variable.

 

So, I read through your description and it doesn't seem as you have to go through all the first and second collection switch arounds.  The colPelMed collection will already have the Facility, Line and Checked Items in it.  So, if a user switches to another Facility, then that is not going to impact the collection.  It will still have the values in it that they put from the other.

When they switch back to the first facility, those items are still there and will be checked off as they had them before.

 

Did I miss something in what I read, or does that sound about right? 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
iwonder
Impactful Individual
Impactful Individual

You are correct, the gallery updates when they switch and switch back.

 

The part I cannot accomplish is if the user selects NONE.... etc.

 

Thanks

RandyHayes
Super User
Super User

@iwonder 

What part are you concerned with in relation to "None" being selected?

With the formulas I provided, if the user selects None, then that will actually be in the collection as a selection.  So when they switch and back and forth, that will still be the case...it will be "None".

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
iwonder
Impactful Individual
Impactful Individual

Truly sorry for not being clear.

 

What I am trying to accomplish is not getting the items into the collection but rather making the gallery reflect what is in the collection. My current code updates the collection as I want, but the gallery does not reflect it.

 

Here is the gallery with the check boxes. "NONE" is checked and my test gallery (to the top right of the picture) shows the same value is in colPelMed

 

gal1.png

 

Then I select "Am" and "NONE" is automatically unchecked and "Am" is added to colPelMed and "NONE" is removed from colPelMed

 

gal2.png

 

Then I select a few more items in the gallery and they are added to colPelMed "Am, Avl, Bmd"

 

gal3.png

 

Then I check "NONE" again. Only "Am" is unchecked, the rest remain checked for some reason, but in colPelMed the only record is "NONE".

 

gal4.png

 

I don't know how to get "Avl" and "Bmd" unchecked. They don't exist in colPelMed.

 

I'm sure I'm missing something very obvious but at the moment I don't know enough to know I don't know 🙂

 

Again, I really really really appreciate all your help, truly.

 

Thanks

Helpful resources

Announcements

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Top Solution Authors
Top Kudoed Authors
Users online (3,825)