cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MinhPham96
Helper III
Helper III

How to patch an option set field

Hello currently I have a travel canvas app with a travel entity, here I have a field called type which is an option set with three values. I used patch to create new travel, and I follow this tutorial to patch an option set field but it did not work. Here are the steps that I did:

 

First I check the value of each option:

2019-12-10_10-48-23.png

 

In the canvas app, I create a collection OnStart

2019-12-10_10-49-06.png

 

Then I stored the collection in a combo box, I also disabled multiple selection option

2019-12-10_10-49-27.png

 

And this is the patch function and the error message (I tried both Selected and SelectedItems from the ComboBox). 

2019-12-10_10-59-35.png

 

Thank you for reading.

 

Best Regards,

 

Minh Pham

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @MinhPham96 ,

Do you want to use a combo box to update an option set?

Actually, you do not need to create a collection to update.

You just need to use "ComboBox1.Selected.Value" to update.

I've made a similar test for your reference:

1)my optionset named: test123

  option set items: New , Registered

  optionset field named: ExpenseStatus 

1211.PNG

 

2)insert a combo box, set the combo box's Items:

Choices(testmanies.'ExpenseStatus ')

3)insert a submit button, set the button's OnSelect:

Patch(testmanies,First(testmanies),{'ExpenseStatus ':ComboBox1.Selected.Value})

Then, click the submit button,you could update option set field.

 

What's more, if you do not use combo box to update an option set field, you just need to use "optionsetname.valuename".

For example:

Patch(testmanies,First(testmanies),{'ExpenseStatus ':test123.New})
Patch(testmanies,First(testmanies),{'ExpenseStatus ':test123.Registered})

 

 

 

Best regards, 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yutliu-msft
Community Support
Community Support

Hi @MinhPham96 ,

Do you want to use a combo box to update an option set?

Actually, you do not need to create a collection to update.

You just need to use "ComboBox1.Selected.Value" to update.

I've made a similar test for your reference:

1)my optionset named: test123

  option set items: New , Registered

  optionset field named: ExpenseStatus 

1211.PNG

 

2)insert a combo box, set the combo box's Items:

Choices(testmanies.'ExpenseStatus ')

3)insert a submit button, set the button's OnSelect:

Patch(testmanies,First(testmanies),{'ExpenseStatus ':ComboBox1.Selected.Value})

Then, click the submit button,you could update option set field.

 

What's more, if you do not use combo box to update an option set field, you just need to use "optionsetname.valuename".

For example:

Patch(testmanies,First(testmanies),{'ExpenseStatus ':test123.New})
Patch(testmanies,First(testmanies),{'ExpenseStatus ':test123.Registered})

 

 

 

Best regards, 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MinhPham96
Helper III
Helper III

Dear @v-yutliu-msft , I looked for hours and never thought the solution is this simple, thank you for your support 

Homerbrown99
New Member

All ... I found that if i used the 'disambiguous' variable name [@optionsetvariable].option ... that it resolved correctly and functioned properly.

Helpful resources

Announcements
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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,955)