cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper IV
Helper IV

How to Filter and update choice column statecode

Hello,

I am trying to filter and patch my choice column statecode .

 

1) gallery: I would like show only statecode is activate

    Filter(tablename,statecode ="Active")

prob.png

2) Update: I would like to change to "inActive" by using a toggle or a checkbox in the gallery.

 

Any help is appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Resolver II
Resolver II

@mssss 

I would write something like :

OnCheck : Patch(datasource,thisitem, {statecode:yourchoice.active})

OnUnCheck : Patch(datasource,thisitem, {statecode:yourchoice.inactive})

 

Regards

-----------------------------------------------------------------------------------------------------

Please accept this as a solution and give it kudos if it helped you achieve your goal. Thank you

View solution in original post

6 REPLIES 6
Helper V
Helper V

One solution could be

 

 

Gallery Items:

 

Filter(
tablename,
statecode.Value =varActiveStatus
)

 

varActiveStatus can be set by setting a context variable in your toggles OnCheck and OnUncheck property.

OnCheck
UpdateContext({varActiveStatus:"Active"})
 
OnUncheck
UpdateContext({varActiveStatus:"Inactive"})
 
You will also need to set the context variable to a default value on the screen's visible property and set a default for your toggle.
 
 

 

 

 

@Digital 

Thank you for your advice😀

I don't know why but not working.

mssss_1-1608713023351.png

 

mssss_2-1608713156507.png

 

 

 

Resolver II
Resolver II

Hello @mssss ,

 

First of all, If you could provide more details maybe we could help you better because I don't quite understand the need.

If I get you, that toggle should be in every row since you say it's in the gallery, otherwise it should be outside.

Here a few things you should take into concideration in case the toggle is for each row

  • If you filter on the active only you won't be able to see the row if you disable it , meaning you won't be able to reactive it.
  • You won't be able to use @Digital 's solution as that context variable will change for each row you click and you wouldn't like that to happen as it messes up your gallery(it will show sometimes active only and sometimes inactive only)
  • You'll need to use a Patch in the OnCheck and OnUnCheck  properties or the OnChange of the toggle to update your row in database.
  • Your statecode column is a choice as the image you provided shows, in the filter you'll need to do something like : Filter(
    tablename,
    statecode = choiceName.Active
    ). You change choiceName by the name of the choice in that column and when you put the "." after, the system will give you the values of the choices and you choose the one corresponding to active.
  • If you have only active or inactive maybe a boolean column would be better otherwise, you'll need to play with the toggle to make it correspond to your active state when checked ( you'll need to write a formula in the default property, something like : if(thisitem.statecode = yourchoice.active,true,false) )

Regards,

Akram

 

--------------------------------

Please accept this a solution and give it kudos if it helped you achieve your goal. Thank you

@awerda 

 

Thank you for your help!

It worked!
Gallery: Filter(tablename,statecode = choiceName.Active). 

Checkbox/default propert : if(thisitem.statecode = yourchoice.active,true,false) )

 

I am sorry but would you please advise me how to pacth/Update to "Inactive"?

Should write on Oncheck and OnUncheckand property.

 

Resolver II
Resolver II

@mssss 

I would write something like :

OnCheck : Patch(datasource,thisitem, {statecode:yourchoice.active})

OnUnCheck : Patch(datasource,thisitem, {statecode:yourchoice.inactive})

 

Regards

-----------------------------------------------------------------------------------------------------

Please accept this as a solution and give it kudos if it helped you achieve your goal. Thank you

View solution in original post

@awerda 

Thank you for your help!It worked perfectly🤗

 

@awerda @Digital 

Thank you to both😊

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (60,429)