cancel
Showing results for 
Search instead for 
Did you mean: 
WarrenBelz

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

Some of you who have read my posts will know 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. 

WarrenBelz_2-1662943729571.png

 

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

 

WarrenBelz_1-1662943694586.png

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.

Comments