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

PowerApps cannot convert Text to an OptionSetValue.

We have a Canvas app where there is a combo box control which corresponds to Multi Select Option Set in Dynamics 365. In order to populate combo box we have filtered the data source of Dynamics 365 entities which uses CDS Current Environment Connector. 

 

Now, the combobox shows the Optionset text and i think there is no possibility to retrieve the option set values from Dynamics 365.

So, I have created a collection which holds all the optionset text and values named "All Items". We need to get the keys of the selected options in that combo box control. We have retrieved the selected optionset texts into a collection named "SelectedOptions". Now that we have two collections (one with all the possible Optionset texts and values - "All Items") and another collection which contains the selected options (SelectedOptions).

 

Requirement is to create a new collection which has two columns for Optionset text and optionset value of the Selected options in the combo box, Below formula is used to do that.

All Items:

OptionsettextOptionsetvalue
Product1

1

Product22
Product33
 

SelectedOptions:

Options

Product1
Product3

 

NewCollection - Desired Output:

OptionsettextOptionsetvalue
Product1

1

Product33

 

ClearCollect(NewCollection, Filter(AllItems, Optionsettext  in SelectedOptions.Options)) - This works when i use Dynamics 365 connector but gives an error on Optionsettext which says "Powerapps cannot convert text to an Optionset value".

 

Please suggest.

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @Chandanajcp ,

 

Here is a easy solution, add a new column to store the option text in SelectedOptions Collection, and then filter by that column.

1.Create a new Collection with the OptionsText column

ClearCollect(SelectedOptionsText, AddColumns(SelectedOptions, "OptionsText", Text(Options)))

2. Filter based on the new collection.

ClearCollect(NewCollection, Filter(AllItems, Optionsettext  in SelectedOptionsText.OptionsText))

Hope this helps.

Sik 

View solution in original post

4 REPLIES 4
v-siky-msft
Community Support
Community Support

Hi @Chandanajcp ,

 

Here is a easy solution, add a new column to store the option text in SelectedOptions Collection, and then filter by that column.

1.Create a new Collection with the OptionsText column

ClearCollect(SelectedOptionsText, AddColumns(SelectedOptions, "OptionsText", Text(Options)))

2. Filter based on the new collection.

ClearCollect(NewCollection, Filter(AllItems, Optionsettext  in SelectedOptionsText.OptionsText))

Hope this helps.

Sik 

Hi @v-siky-msft ,

 

Many thanks to you, This solved my issue 🙂

dazzerd
Helper I
Helper I

Actually almost there I think:

 

Collect(LegacyActivityLogs,ForAll(LegacyActivities,{Request_ID:DataCardValue7.Text,
ActivityID:ThisRecord,
Request_Activity:DataCardValue7.Text & ThisRecord.LegacyActivities
}))

 

Problem now is I have a default value in legacyactivitylogs called activity_isna which is a set option of yes or no. But I cant actaully simply add 0 to my statment to refer to no

dazzerd
Helper I
Helper I

Ignoe that wrong thread!

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 (7,182)