cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

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

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

Thanks Carlos; info was very helpful.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (13,133)