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

OptionSet value switch statement with "Relational data, option sets, and new features for CDS" not working offline

Please be so kind as to read my full post before responding.
Thank you for your consideration.

To make part of my PowerApp configurable for users, I had modeled some option sets in Dynamics after PowerApps option sets and used to translate those to PowerApps using code similar to

UpdateContext({align_body: Switch(configPlain._kk_align_body_label,
    "Left", Align.Left,
    "Center", Align.Center,
    "Right", Align.Right
)})

The _*_label was the "old" way to access (multiselect) option sets.
This also works/worked offline in airplane mode on my android phone.

However, I have to use the Preview feature "Relational data, option sets, and new features for CDS" (default on with PowerApps version 3.19032.13 at the time of writing), also because it solves another problem I had been facing before.
https://powerusers.microsoft.com/t5/General-Discussion/PowerApps-Dynamics-9-MultiSelect-Option-Set-e...

This new feature changes the syntax of how (multiselect) option sets are accessed via PowerApps.
In particular the _*_label thingy is not necessary anymore with the new features.
So the syntax of my former piece of code from above changed to

UpdateContext({align_body: Switch(configPlain.kk_align_body,
    'PowerApps Align'.Left, Align.Left,
    'PowerApps Align'.Center, Align.Center,
    'PowerApps Align'.Right, Align.Right
)})

with 'PowerApps Align' being the name of the global option set used in Dynamics to represent PowerApps behaviour.


However, this new version using new CDS option set features does not seem to work offline anymore while the older version without the new preview feature does.
I tested this on my phone using PowerApps in airplane mode.
I am guessing that 'PowerApps Align'.Left etc needs to be read online from the server.
image.png


I have also tried and tested with digging up the numerical values and using those directly, but this yieldsimage.png
Hence, this
https://powerusers.microsoft.com/t5/PowerApps-Community-Blog/Working-with-CDS-Entity-Option-Set-fiel...
also doesn't work anymore with the new CDS features.

My question:

  1. How do I make my OptionSet Switch statement work offline (in airplane mode) with the new CDS option set features?
1 ACCEPTED SOLUTION

Accepted Solutions
SaWu
Level 8

Re: OptionSet value switch statement with "Relational data, option sets, and new features for CDS" not working offline

Found a workaround that seems to work offline as well.
At App.OnStart get all option set values and set association

Set(isBrowser, !(CountRows(SaveData(["1", "2"],"isBrowserTest").Value)=2));
If(Connection.Connected,
    ClearCollect(AlignAssoc,
        {key: 'PowerApps Align'.Left, value: Align.Left},
        {key: 'PowerApps Align'.Center, value: Align.Center},
        {key: 'PowerApps Align'.Right, value: Align.Right}
    );
    If(!isBrowser, SaveData(AlignAssoc, "AlignAssoc")),
    !isBrowser,
    LoadData(AlignAssoc, "AlignAssoc")
)

And the switch statement becomes a lookup

UpdateContext({align_body: LookUp(AlignAssoc, key=userConfig.kk_align_body, value)})

View solution in original post

1 REPLY 1
SaWu
Level 8

Re: OptionSet value switch statement with "Relational data, option sets, and new features for CDS" not working offline

Found a workaround that seems to work offline as well.
At App.OnStart get all option set values and set association

Set(isBrowser, !(CountRows(SaveData(["1", "2"],"isBrowserTest").Value)=2));
If(Connection.Connected,
    ClearCollect(AlignAssoc,
        {key: 'PowerApps Align'.Left, value: Align.Left},
        {key: 'PowerApps Align'.Center, value: Align.Center},
        {key: 'PowerApps Align'.Right, value: Align.Right}
    );
    If(!isBrowser, SaveData(AlignAssoc, "AlignAssoc")),
    !isBrowser,
    LoadData(AlignAssoc, "AlignAssoc")
)

And the switch statement becomes a lookup

UpdateContext({align_body: LookUp(AlignAssoc, key=userConfig.kk_align_body, value)})

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,941)