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:
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.
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.
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.
Hi @Anonymous,
The design I went with in the end was to cache the Options of ALL option sets (including each individual OOTB Yes/No). This was not ideal as there was over 100 option sets and they were re-loaded every time the app was started, but it was the best solution I came up with at the time.
In order to use Toggle controls, I used an IF expression when capturing my data. something like:
IF(toggle.value, Lookup(myLocalOptionSet, Text(Value) = "Yes", Value), Lookup(myLocalOptionSet, Text(Value) = "No", Value))
I can't remember the exact syntax.
User | Count |
---|---|
151 | |
94 | |
85 | |
77 | |
58 |
User | Count |
---|---|
193 | |
175 | |
105 | |
95 | |
90 |