cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
luizhr
Advocate I
Advocate I

If condition for a checkbox gallery

luizhr_0-1641840728865.png

 

I'm stucked in a "If condition", hope someone could help me. I have a checkbox inside a gallery (picture above) and I want to make a condition in a dropdown list based on the responses above:

 

What I want to do:

CONDITION 1: Every time "Task List" is checked, the dropdown (DefaultSelectedItems) will be "Pendente", regardless if other item is checked; 

CONDITION 2: If any other item is checked (eg. "Frequência", Outros, etc) the dropdown (DefaultSelectedItems) will be Parent.Default 

 

ONUNCHECK: Remove(ColAtualizacaoPM,ThisItem);UpdateContext({Var:Gallery13.Selected.Checkbox2.Text="Task List"=true});If(Gallery13.Selected.Checkbox2.Text="Frequência"=true,UpdateContext({Var2:true}))

 

ONCHECK: Collect(ColAtualizacaoPM,ThisItem);UpdateContext({Var:Gallery13.Selected.Checkbox2.Text="Task List"=false});If(Gallery13.Selected.Checkbox2.Text="Frequência"=true,UpdateContext({Var2:false}))

 

If(Gallery13.Selected.Checkbox2.Text="Task List"=Var,{Value:Parent.Default},If(Gallery13.Selected.Checkbox2.Text="Task List"=true,{Value:"Pendente"},If(And(Var=true,Var2=false),{Value:"Pendente"},Parent.Default))))))

 

My issue is to find the right formula, and the right combination in the "oncheck" and "onuncheck"

1 ACCEPTED SOLUTION

Accepted Solutions
JordanDeVan
Advocate I
Advocate I

Ok so this is inside of a form, I wasn't understanding where how the Parent.Default made sense.

 

What are you using the context variables for? It almost seems as if you could do something like this.

 

Oncheck = Collect(ColCollection,ThisItem);

OnUnCheck = Remove(ColCollection,ThisItem);

 

In the default selected property of what looks to be a combobox

I would do something like this. 

 

If("Task List" in ColThisItem.ItemName,["Pendente"],[Parent.Default])

View solution in original post

6 REPLIES 6
luizhr
Advocate I
Advocate I

@WarrenBelz ,  @RandyHayes you guys are PowerApps top solution, could you help me out in this task 🙂  Or know someone that could help me ? 

 

JordanDeVan
Advocate I
Advocate I

It seems like you're asking for a cascading dropdown. Where does the dropdown live, inside or outside of the gallery?

The dropdown is outside the gallery

 

luizhr_0-1641997912726.png

 

JordanDeVan
Advocate I
Advocate I

Ok so this is inside of a form, I wasn't understanding where how the Parent.Default made sense.

 

What are you using the context variables for? It almost seems as if you could do something like this.

 

Oncheck = Collect(ColCollection,ThisItem);

OnUnCheck = Remove(ColCollection,ThisItem);

 

In the default selected property of what looks to be a combobox

I would do something like this. 

 

If("Task List" in ColThisItem.ItemName,["Pendente"],[Parent.Default])

RandyHayes
Super User
Super User

@luizhr 

You need no collections for any of this unless you are using it for something else within your form (as Galleries in forms have a bug that is a challenge to work around).

So, the first question is, is this Gallery IN a datacard in your form?  If so, do you have the possibility to move it outside of the form (you can overlay it just as it is, but not be in the form)?

The key is moving this out of the form and then you will need no collections nor need to worry about OnCheck and OnUncheck.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you very much @JordanDeVan for all the support, just correcting the formula sent by you, if someone else you'd like to do the same: 

If("Task List" in ColAtualizacaoPM.Value,{Value:"Pendente"},Parent.Default)

🙂

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,621)