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

 

@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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,679)