cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Impactful Individual
Impactful Individual

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
Highlighted
Impactful Individual
Impactful Individual

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
Highlighted
Impactful Individual
Impactful Individual

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
Check this Out

Announcing

Class of 2020- Season 2

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

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

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,003)