cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helpful
Level 8

Unable to Patch CDS entity option set value from drop down selection

I have a custom CDS entity, Time Entry, with a local option set defined, "Time Type".

In my canvas app, the setting for "Relational data, option sets, and other new features for CDS" is ENABLED

It has two screens:

  1. Gallery of Time Entries - when a user selects a record the SelectedTimeEntry variable is set to ThisItem
  2. Form of a single Time Entry - fields load data from SelectedTimeEntry if it's not blank

 

On the form, dropdown properties are set like:

Items = Choices('Time Entries'.'Time Type')
Default = If(!IsBlank(SelectedTimeEntry), SelectedTimeEntry.'Time Type', Blank())

The form loads values as expected.

 

I have a button on which I have tried different Patch formulas:

OnSelect = Patch('Time Entries', SelectedTimeEntry, {'Time Type': DrpEntryType.Selected})

This syntax produces the error message:  "The type of this argument 'abc_timetype' does not match the expected type 'OptionSetValue'.  Found type 'Record'."

OnSelect = Patch('Time Entries', SelectedTimeEntry, {'Time Type': DrpEntryType.Selected.Value})

This syntax produces the error message:  "The type of this argument 'abc_timetype' does not match the expected type 'OptionSetValue'.  Found type 'Text'."

 

I have reviewed some videos and other materials that suggest one of the prior options should work.  I see other posts where they resolve the issue by explicitly coding an option set value like this:

OnSelect = Patch('Time Entries', SelectedTimeEntry, {'Time Type': 'Time Type (Time Entries)'.Work})

While this syntax functions as expected (the Type is updated to Work), it doesn't allow the user to specify the value using the dropdown.

 

Any thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions
Helpful
Level 8

Re: Unable to Patch CDS entity option set value from drop down selection

Hi @Lachlan_w ,

I ended up changing all of my drop downs to comboboxes.  I did this change for things that allow users to select from an Option Set, as well as an entity LookUp.  I deselect "Allow multiple selections" in both cases for my needs because I want them to basically bahave like a drop down.

The patch now works correctly and looks like this:

OnSelect = Patch('Time Entries', SelectedTimeEntry, {'Time Type': ComTypeEntryValue.Selected.Value})

My combobox items are populated like this:

Items = Choices('Time Type (Time Entries)')

And the "Primary Text" property of the combobox is set to "Value".

 

I then had the issue of how to set them to empty after a user visits the screen.  My data does not have any blank records in it so I need the controls to appear blank before a user selects a value when creating a new record (vs. editing an existing one).

First I reset my comboboxes using the screen's "OnVisible" property:

OnVisible = Reset(ComTypeEntryValue);

Then on the combobox:

DefaultSelectedItems = If(!IsBlank(SelectedTimeEntry), Filter(Choices('Time Entries'.'Time Type'),Value=SelectedTimeEntry.'Time Type'), Blank())

Hope that helps!  Since this does what I set out to accomplish I'm going to mark this as the solution.

3 REPLIES 3
Helpful
Level 8

Re: Unable to Patch cds entity option set value from drop down selection

I see now that a drop down control won't support this scenario since it only stores one column (in this case the Label of the option).

I'm going to try to use a combox box and see if I can get it working.

Lachlan_w
Level: Powered On

Re: Unable to Patch CDS entity option set value from drop down selection

Hello - How did you go with this? I am stuck with the same thing.

Helpful
Level 8

Re: Unable to Patch CDS entity option set value from drop down selection

Hi @Lachlan_w ,

I ended up changing all of my drop downs to comboboxes.  I did this change for things that allow users to select from an Option Set, as well as an entity LookUp.  I deselect "Allow multiple selections" in both cases for my needs because I want them to basically bahave like a drop down.

The patch now works correctly and looks like this:

OnSelect = Patch('Time Entries', SelectedTimeEntry, {'Time Type': ComTypeEntryValue.Selected.Value})

My combobox items are populated like this:

Items = Choices('Time Type (Time Entries)')

And the "Primary Text" property of the combobox is set to "Value".

 

I then had the issue of how to set them to empty after a user visits the screen.  My data does not have any blank records in it so I need the controls to appear blank before a user selects a value when creating a new record (vs. editing an existing one).

First I reset my comboboxes using the screen's "OnVisible" property:

OnVisible = Reset(ComTypeEntryValue);

Then on the combobox:

DefaultSelectedItems = If(!IsBlank(SelectedTimeEntry), Filter(Choices('Time Entries'.'Time Type'),Value=SelectedTimeEntry.'Time Type'), Blank())

Hope that helps!  Since this does what I set out to accomplish I'm going to mark this as the solution.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 191 members 4,555 guests
Please welcome our newest community members: