cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KickingApps Skilled Sharer
Skilled Sharer

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
Power Apps
Power Apps

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
Power Apps
Power Apps

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 Skilled Sharer
Skilled Sharer

Re: Is it possible - Set a variable from collection

Thanks Carlos; info was very helpful.

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Attending MBAS? Claim your badge

Attending MBAS? Claim your badge

Whether you’re streaming the digital event live, or watching on-demand, claim your attendee badge to sport on your profile.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

‘Better Together’ Integration Forum Launch

‘Better Together’ Integration Forum Launch

We're launching a how-to forum where you can learn about how Power BI integrates with other Power Platform products.

Emergency Response & Monitoring Solution

Emergency Response & Monitoring Solution

Microsoft has created a regional government emergency response and monitoring solution that is built on Power Apps and Power BI.

Top Solution Authors
Top Kudoed Authors
Users online (5,589)