cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KickingApps
Level 8

Is it possible - Set a variable from collection

Suppose I have a collection of variables.  Is it possible to set the variables based on the values in a collection via a Button and the Select function? A bit of an out there question, I realize.  

Collect(
    colTestVariable,
    {
        id: "1", formula: Set(gloIsTrue, true)
    },
    {
        id: "2", formula: UpdateContext({varShowImage:true})
    }
)

Button
Select(Lookup(.....)  or
Select / If 
1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Is it possible - Set a variable from collection

Not really - collections can only store data, not actions or behaviors. You can store some code in the collection, and then execute the logic on a button press. For example, if you have this collection in a gallery:

ClearCollect(
    colTestVariables,
    { id: "1", name: "Set global gloIsTrue" },
    { id: "2", name: "Set context varShowImage" })

You can have a button outside the gallery that takes action based on the selected item:

Switch(
    Gallery1.Selected.id,
    "1", Set(gloIsTrue, true),
    "2", UpdateContext({ varShowImage: true })
)

Hope this helps!

View solution in original post

2 REPLIES 2
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Is it possible - Set a variable from collection

Not really - collections can only store data, not actions or behaviors. You can store some code in the collection, and then execute the logic on a button press. For example, if you have this collection in a gallery:

ClearCollect(
    colTestVariables,
    { id: "1", name: "Set global gloIsTrue" },
    { id: "2", name: "Set context varShowImage" })

You can have a button outside the gallery that takes action based on the selected item:

Switch(
    Gallery1.Selected.id,
    "1", Set(gloIsTrue, true),
    "2", UpdateContext({ varShowImage: true })
)

Hope this helps!

View solution in original post

KickingApps
Level 8

Re: Is it possible - Set a variable from collection

Thanks Carlos; info was very helpful.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 317 members 5,225 guests
Recent signins:
Please welcome our newest community members: