cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MWierckx
Advocate I
Advocate I

How to add option set field value to new collection in Power Apps

Dear all,

 

Struggling with the following.

 

In a Power App I'm creating a collection (collection_A) which is combining all quote products from different quotes together based on the fact that they have the same customer.

 

In the collection I want to add an option set field (ProductGroup) which is stored on the Product entity related to the Quote Product.

But I can't seem to find the right syntax to do this.

 

So I have Quote (entity) >

                          QuoteProduct (entity) >

                                                 Product (entity) - ProductGroup (option set)

 

The syntax I have now is the following:

 

ForAll(
    Quotes;
    ForAll(
        Filter(
            QuoteProducts;
            Quote.Quote = GUID(quote_id)
        );
        Collect(
            collection_A;
            {
                Quote_ID_A: Quote.Quote;
                QuoteProduct_A: QuoteProduct;
                QuoteProduct_Product_A: Product.Product;
                QuoteProduct_Product_ProductGroup_A: Product.ProductGroup
            }
        )
    )
)

 

 

I also tried to use a LookUp:

 

ForAll(
    Quotes;
    ForAll(
        Filter(
            QuoteProducts;
            Quote.Quote = GUID(quote_id)
        );
        Collect(
            collection_A;
            {
                Quote_ID_A: Quote.Quote;
                QuoteProduct_A: QuoteProduct;
                QuoteProduct_Product_A: Product.Product;
                QuoteProduct_Product_ProductGroup_A: LookUp(
                   Products;
                   Product = Product;
                   ProductGroup
                   )
            }
        )
    )
)

 

Doesn't work either.

 

Is there anybody who can tell me what the right syntax should be?

 

The datesource is CDS and the entities and fields are coming from Dynamics 365 CE

 

Appreciating the help!

 

Awaiting your response.

 

Best regards,

 

MWierckx

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @MWierckx ,

 

Does the OptionSet Field allow Multi-selection?

I made a test on my side, but it can work properly based on your code. Could you please share the error message on the code? 

Snipaste_2020-06-30_17-06-07.png

Sik

 

View solution in original post

4 REPLIES 4

when you say it doesn't work, what is it getting you? Is it getting you the options but not the labels? I recommend Michael G's post about option sets https://michalguzowski.pl/how-to-work-with-option-set-in-powerapps/

 

If you can get the option set number value, there is a tool in the XrmToolBox (www.xrmtoolbox.com)  called the Power BI Option Set Assistant that is really helpful--it syncs all of the option sets in your environment to a an entity with the label and value for each, so you can join to that entity to translate number values to labels.

 

 

Hi @jlindstrom,

 

Thanks for the reply.

 

I did found Michael his post about option sets, which was helpfull for me to filter in other action that I'm doing in the Power App. However it's not giving me the value or label of the selected option when retrieving the records to a new collection.

 

Currently the syntax is giving an error, so nothing is happening.

 

I'm not aware of the Power Bi option set Assistent, so I'll dive into that.

 

I'll let you know if it works!

v-siky-msft
Community Support
Community Support

Hi @MWierckx ,

 

Does the OptionSet Field allow Multi-selection?

I made a test on my side, but it can work properly based on your code. Could you please share the error message on the code? 

Snipaste_2020-06-30_17-06-07.png

Sik

 

View solution in original post

@v-siky-msft,

 

Thanks for the help, looking at your example I was able to figure out my mistake.

 

Before excuting the Collect I have a ClearCollect in which I'm creating the table. During this creation I was telling the table that the option set column needed to be a text variable (which it isn't). 

Sorry, stupid of me.

 

Thanks again.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,367)