cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

CDS Connector Option Set - Any way to patch with a number?

I have a Canvas App used for offline data capture that has been in use for about a year. It uses the "Dynamics 365" Connector, and I am now looking at migrating it to the new CDS Connector, but it's turning out to be a more complex transition than I had initially hoped. I'm having an issue with the Option Sets.

 

Option Sets and the Dynamics 365 Connector

The Canvas App has > 100 Combo Box controls for data capture. The items in these controls have Number values behind them which map to option set values in Dynamics/CDS. When capturing data with the Dynamics 365 Connector, i just need to reference the number value and it saves the option set in the record. This is ideal, as for the offline functionality, I don't need to cache 100+ option sets in the device.

 

Collect(MyCollection,{
    new_myfield: 1
});
Patch('My Records', MyCollection)

 

 

CDS Connector

So with the CDS Connector, it wants me to reference that specific option set, which seems to be a data type of it's own in PowerApps. If I pass in a number, I get an error saying: "The type of this argument 'new_myfield' does not match the expected type 'OptionSetValue'. Found Type 'Number'. " . I can't create an enum or OptionSetValue using the number at runtime. With other Canvas Apps that have fewer Option Sets, I have successfully achieved the offline functionality with CDS connector by saving the Option Sets to the device, and then loading them into the choices into the combo boxes. If possible, I would like to avoid this, due to the high number of option sets.

 

What I'm looking for is a way to get write an Option Set Value to CDS from a number in PowerApps. There is a helpful solution in this post (https://powerusers.microsoft.com/t5/Building-Power-Apps/CDS-Two-Options-number-Singe-Check-Box/m-p/4...) that shows how to reference a CDS option set by its value. This doesn't work for me however, as the value must be wrapped in single quotes, and I need to dynamically reference the value using the selected item of the combo box.

The other two ways I'm approaching this are:

  1. Trying to cast the Number as an OptionSet when I capture the data to a collection. This doesn't seem to be achievable through PowerApps formulas.

    or
  2. Getting the OptionSetValue from the number value when patching to the Data Source (as the device will always have connection, and thus be aware of the option sets when writing records to CDS). I'm trying to achieve this by using a Lookup() on the Option Set choices, but there is no attribute of the choices that I can use in the condition. The 'Value' keyword doesn't match the type of the Number

 

Collect(MyCollection,{
    new_myfield:LookUp(Choices('My Option Set'), Value = 1)
});​

 

 

I hope this makes some sense.

 

Any ideas on this would be greatly appreciated, though I realise I may have to resort to caching all of the option sets.

 

Thanks,

-Tadhg.

 

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: CDS Connector Option Set - Any way to patch with a number?

Hi,

 

Looking through this, I am not certain on how to make this interaction work in the way you want either. This might be a better question to bring to the Microsoft Support team. I will include a link below; on how to do so. Unless any other communities members have any idea how to do this, feel free to chime in.

 

If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so: https://docs.microsoft.com/en-us/power-platform/admin/get-help-support

 

Regards,

 

Alex

 

-------

 

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

Highlighted
Helper IV
Helper IV

Re: CDS Connector Option Set - Any way to patch with a number?

Hi @Tadhg- ,

Have you found any solution? I am facing the similar issue. I am using two option set having Yes and No items. Not able to use toggle in collect function for offline mode.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,392)