cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jan-Ph
Helper I
Helper I

Get Dataverse Choices with Label and ID(Value)

Hey Guys,

 

Im trying to get from Dataverse a choice list. I want to get the choices to put them in an adaptive Card.

JanPh_0-1652105579029.png

Unforunately powerautomate (In powerapps) is not showing me any option to select them.

Has somebody an idea?

 

Regards Jan

3 REPLIES 3
ekarim2020
Super User
Super User

I don't work much with Datavse, but I had an "old" flow that I wrote to get the Option set text and value as a JSON object. You should be able to modify it to suit your needs. It produces the following object:

{
  "Apple": 544500000,
  "Pear": 544500001,
  "Banana": 544500002,
  "Mango": 544500003
}

If you specify a property, it will return the option set value:

outputs('Compose_Mapped_Table_2')?['Apple'] ---> 544500000
outputs('Compose_Mapped_Table_2')?['Mango'] ---> 544500001
outputs('Compose_Mapped_Table_2')?['Banana']---> 544500002
outputs('Compose_Mapped_Table_2')?['Pear']  ---> 544500003

 

Snag_3eadb62.png

 

ekarim2020_0-1652110800474.png

Snag_3d3b135.png

/api/data/v9.1/GlobalOptionSetDefinitions(Name='crc37_fruitchoice')

Snag_3d65192.png

"UserLocalizedLabel": item()['Label']['UserLocalizedLabel']['Label']
"Value": item()?['Value']

Select Value 2 produces:

[
  {
    "UserLocalizedLabel": "Apple",
    "Value": 544500000
  },
  {
    "UserLocalizedLabel": "Pear",
    "Value": 544500001
  },
  {
    "UserLocalizedLabel": "Banana",
    "Value": 544500002
  },
  {
    "UserLocalizedLabel": "Mango",
    "Value": 544500003
  }
]

 

Snag_3dbe994.png

item()?['UserLocalizedLabel'] 
item()?['Value']

The Select Value 2 produces:

[
  {
    "Apple": 544500000
  },
  {
    "Pear": 544500001
  },
  {
    "Banana": 544500002
  },
  {
    "Mango": 544500003
  }
]

 

Snag_3de6ff0.png

json(replace(replace(replace(string(body('Select_Key_Value_Pairs_2')),'[',''),']',''),'},{',','))

The expression converts the previous output into a JSON object:

{
  "Apple": 544500000,
  "Pear": 544500001,
  "Banana": 544500002,
  "Mango": 544500003
}

There is also another method that uses the String Maps Table.

 

Hope this helps.

 

Ellis

Hmm okeay not i need it get queried otherwise its to much effort to change it in every Flow manually. Is this task easier done with lists ?

It depends on what you need or how you want to use the option sets. 

 

A manual way to get the values and then hardcode them into the flow/app:

Snag_7631aec.png

  

Snag_7642db4.png

For each choice field value, select View more to display the option set value:

 

Snag_764fbf1.png

Unfortunately the option set value is displayed with commas:

Snag_7618e03.png

 

Hope this helps.


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,073)