cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jasreich
Regular Visitor

Use multiple buttons to change mutiple shape colors

Hello, I am a newbie, and I'm trying to create a map of a campus and list out all of the roadways on the campus.  I want to put buttons down the side of the map corresponding to each roadway.  Then when the buttons are clicked, it would turn a specific road label from green to red.  I put in the map as a background image, and inserted a few labels over the streets and used put in a couple buttons to test it.  When I click a button it changes all of the labels from green to red.  I was using the toggle function.  I'm trying to figure out how to tie a specific label to a specific button so when I put in 20 buttons and 20 labels all can be toggled independently.  It feels like this should be a very simple, single screen app to make, but I'm stuck.  Any help would be appreciated and if there is a better way to do this, I'm all ears.  

9 REPLIES 9
SpongYe
Super User
Super User

Hi @Jasreich 

 

To achieve this I would suggest to make use of variables. 

Use the Set function to set the value of a global variable, which temporarily holds a piece of information, such as the number of times the user has selected a button or the result of a data operation.

 

Set( varMainColor, RGBA(255, 255, 255, 1) )

 

And then you use to toggle to enable the variable.

 

https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-set

 


-----------------------
PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

Ben_L
Regular Visitor

Hey Jasreich,

 

You can reference properties of controls by placing a dot after the control (e.g. Label1.'Property').

 

Unfortunately, you can't individually change the Fill property of Labels due to their design. What I would do is place rectangles over the labels and then set the fill properties of the rectnagles as variables. Then I would set the buttons OnSelect properties to change the variables color. You need to make sure that the label is in front of the rectangle though, so the text is visible. You can do this buy right clicking the label click reorder and send to front. 

 

I've put together a little walkthrough of how I would do it,

 

Ben_L_0-1695561124418.png

Ben_L_1-1695561159152.png

 

 

Then you would just have to repeat this for each respective label/button. 

 

Hope this helps man, let me know how it goes.

 

Ben_L
Regular Visitor

Sorry SpongYe, just seen you had dropped a response, hadn't loaded in for me.

Hey Ben_L, thanks for the speedy reply.  With your example, once I press the button to change the rectangle color, will I be able to press it again to change it back?  I will need to change it from red to green frequently throughout the day.  This is almost like a manual desk reservation system.  Someone sits at a desk and the proctor will click that desk on the seating chart and turn it red.  When the person gets up, they will click again and turn it green.  Same concept, except I am doing it with roadways on the campus and I wanted to have a list of those roads down the side of the map to click and control the colors.  Someone will call security and request to block a road and security will click the button and turn the road red until they get a call back that the road isn't blocked any longer.  Hopefully that makes sense.  Thanks so much!

 

Hey Jasreich, I've adjusted the code to suit this, each time you click it it will adjust its color. 

Ben_L_0-1695639508361.png

Ben_L_1-1695639554577.png

The way this works is it starts a tally when you click it, when its even its red, when its not its Green and clicking each time adds one to the tally. 

 

You can repeat this for each by setting a new variable.

 

Hope this helps :),

 

 

Ben_L
Regular Visitor

For more explanation, for the second variable you might do Button2.OnSelect = Set(ColorVariable2, ColorVariable2+1) and then Reactangle2.Fill =

If(
Mod(Value(ColorVariable2), 2) = 0,
Color.Red,
Color.Green
)

Ben_L
Regular Visitor

Its also worth noting that these values will reset when you exit the app. Since data is only temporarily stored on powerapps you could avoid this by utilizing a sharepoint list to store the data so it stays that color regardless of whether you leave the app or not.

 

If this interests you more than happy to give you a walkthrough 🙂

I used the code you provided above to make the buttons independently control the labels.  It works great.  Thank you!  Another question...My hope was I could have a couple people in our security headquarters that could click the buttons and keep a real time view of open/blocked roads.  Looks like this part will work.  What I don't know is, "How can I make it so many others can view this?"  I have the app open on my phone and my PC and when I make a change on the PC it does not update/change on the phone.  I'd like to have it connected to a large TV in our headquarters that provides a realtime view and allow other people to access it from their phones with the reatime view.  Is this possible, or not something that Power Apps can do?  I do not want everyone who views to be able to click the buttons and change the map.  Sorry I'm not better at this, but I appreciate your help!

 

Apologies for the delayed response,

 

No stress at all, happy I can be of help :D,

 

Its definitely possible but since its not utilizing locally stored data (since numerous people need to access it) you would have to use a database to store the data (I would say sharepoint lists is best since its free and more than capable of doing the job).

 

Firstly, Ill show you the structure of the list,

Ben_L_0-1695717959916.png

It contains the Title column and the Colour Column which is a text datatype column. Title is the default Title datatype. 

 

Next, make the connection to the list in PowerApps. Go to 'Add Data' > Sharepoint > Add A Connection > It will open up a page where you can add the sharepoint connection > Go back to the App > Ensure it is connected or else select that connection again. 

 

Once its connected, use the Patch function like so (Noting my list is called Test List, and my first Table has the Title column value of Table 1 etc,

 

Ben_L_1-1695719356976.png

 

Ben_L_2-1695719439139.png

 

This will actually live update the datbase so anyone who is using the app will be able to update these. It would be worth placing a timer on the screen too so it refreshes the list every 3 seconds or so.

 

For your convenience here is the code noting you will have to do this for every table/traffic light:

 

If(
LookUp('Test List', Title = "Table 1").Colour = "Red",
Patch(
'Test List',
LookUp('Test List', Title = "Table 1"),
{
Colour: "Green"

}

),
LookUp('Test List', Title = "Table 1").Colour = "Green",
Patch(
'Test List',
LookUp('Test List', Title = "Table 1"),
{
Colour: "Red"

}

)
)

2nd code:

If(
LookUp('Test List', Title = "Table 1").Colour = "Red",
Color.Green,
Color.Red
)

 

Hope this helps 🙂

 

If you need more tailored advice, feel free to reach out on DM.

 

 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (901)