cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Set a OptionSetValue Variable with a button

Hi All,

I have a CDS Option Set Field called Site with Site A, Site B, Site C as the options.

In my app I have a dropdown with Items Choices('Source'.Site)

The OnChange sets a variable - "Set(GblSiteSelected, Dropdown1.Selected.Value)"

This gives me a Variable of the type "OptionSetValue"

Capture1.JPG

This variable is used throught the app in filters, lookups, patch.

 

The end user now wants 3 x buttons instead of a dropdown to set the site.

Setting the variable as a String doesn't work as all my filters etc expect an OptionSetValue.

Any idea what formula to use in my OnSelect to update the variable with the site name?

Capture2.JPG

Thanks

 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Set a OptionSetValue Variable with a button

Hi @RobH1 

You can accomplish this by looking up the value that you want to set, using the choices function as the data source.

For your 'Site A' button, the formula would look like this:

 

Set(GblSiteSelected, 
    LookUp(Choices('Source'.Site), Text(Value)="Site A").Value)
)

For your other two buttons, you would substitue "Site A" with "Site B" and "Site C".

 

View solution in original post

12 REPLIES 12
Highlighted
Resolver II
Resolver II

Re: Set a OptionSetValue Variable with a button

What is your issue?

Highlighted
Frequent Visitor

Re: Set a OptionSetValue Variable with a button

Hi, For some reason it kept posting only half my post, I have edited it now.

Highlighted
Community Champion
Community Champion

Re: Set a OptionSetValue Variable with a button

Try

Set(GblSiteSelected, Dropdown1.Selected.Site)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Frequent Visitor

Re: Set a OptionSetValue Variable with a button

Hi,  The dropdown I currently have is working but the end user wants to get rid of the dropdown and use buttons instead.  I need a button to set the variable. 

Highlighted
Community Champion
Community Champion

Re: Set a OptionSetValue Variable with a button

Try:
Button 1: Set(GbSiteA,"Site A")
Button 2: Set(GbSiteB,"Site B")
Button 3: Set(GbSiteC,"Site C")

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Community Champion
Community Champion

Re: Set a OptionSetValue Variable with a button

Just checking if the issue is resolved

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Frequent Visitor

Re: Set a OptionSetValue Variable with a button

Hi,  Unfortunately this doesn't solve the problem.  It needs to be one Variable and can't be a string.

Highlighted
Community Champion
Community Champion

Re: Set a OptionSetValue Variable with a button

I dont understand "It needs to be one Variable and can't be a string."

A variable can contain string or numbers or even boolean

Can you explain further

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Frequent Visitor

Re: Set a OptionSetValue Variable with a button

Hi,  Please have another look at my original post as it originally only posted half of the problem but has since been updated, it explains I need Variable type OptionSetValue.  Many thanks

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,061)