Functionality,  Helpful hints

Choices columns – manage in SharePoint by Admin, but use Text field for Power Apps

If you have read some of this site’s blogs, you may deduce that I have an aversion to complex column types for data fields in Power Apps unless there is a good and necessary reason to use them. On the lesser end of this scale, Choice columns cannot be used to Sort by in a Delegable manner and still in general add a level of complexity that may not be needed if you are only using single choices.
You can of course “hard code” them in Power Apps Drop-down /Combo Box controls, but any changes require design privileges in Power Apps, not something you always want.

So how do you write back to the desirable Text column, while still allowing some management of the Choices without Developer involvement ?

I recently tested the process described below on a new field production app and it worked very well. This test example has a “master” SharePoint list called ChoiceStore as per the image below and you can see five different lists of choices of varying numbers. 

At App OnStart, I create a Global Record Variable gblChoices as below (the With() statement is only to avoid the Delegation warning) and set each field in the Variable to a sorted list of the relevant column where a value is present. You could also use a Collection here.

With(
   {wChoices: ChoiceStore},
   Set(
      gblChoices,
      {
         Animals: Sort(
            Filter(
               wChoices.Animals,
               !IsBlank(Animals)
            ).Animals,
            Animals
         ),
         Birds: Sort(
            Filter(
               wChoices.Birds,
               !IsBlank(Birds)
            ).Birds,
            Birds
         ),
         Fruit: Sort(
            Filter(
               wChoices.Fruit,
               !IsBlank(Fruit)
            ).Fruit,
            Fruit
         ),
         Vegetables: Sort(
            Filter(
               wChoices.Vegetables,
               !IsBlank(Vegetables)
            ).Vegetables,
            Vegetables
         ),
         Colours: Sort(
            Filter(
               wChoices.Colours,
               !IsBlank(Colours)
            ).Colours,
            Colours
         )
      }
   )
)

The Items of the Combo Box / Drop-down is then simply (example)

gblChoices.Animals

All that is need then is the Update of the Data Card (using a Combo Box called cbAnimals)

cbAnimals.Selected.Animals

to write back to a Text field.

As mentioned, maintenance of this does not require even SharePoint design privileges, just Contribute on the SharePoint list.

Leave a Reply

Your email address will not be published.