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

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
awerda
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
Digital
Responsive Resident
Responsive Resident

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

 

 

 

awerda
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.

 

awerda
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (12,965)