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

visible fields based on toggle

I am trying to set a fields viable depending on if a toggle is true, 

 

If the first part its if toggle 1 is true to set value P to true

on second toggle it is to set only C to true 

 

but if both toggles are true to set both C and P as true

 

The first two parts work, its only when both are true is it not showing both P and C as true

 

Here is my code this is done on the select of a button. 

 

If(Toggle2.Value, true; Set(c, false) & Set(p, true) & Set(i, false), If(Toggle1.Value, true; Set(c, true) & Set(p, false) & Set(i, false), If(Toggle1.Value, true & Toggle2.Value, true, Set(c, true) & Set(p, true) & Set(i, false))))

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@amyharkus86 

 

In this case, you can use the following formula on your next button:

 

 

If(
    Toggle1.Value && Toggle2.Value = false,
    Set(c,true);Set(p,false);Set(i,false),
    If(
        Toggle2.Value && Toggle1.Value = false,
        Set(c,false);Set(p,true);Set(i,false),
        If(
            Toggle2.Value && Toggle1.Value,
            Set(c,true);Set(p,true);Set(i,false),
            Set(c,false);Set(p,false);Set(i,false)
        )
    )
)

 

 

Then, on all the fields that need to be visible/not visible, add the corresponding variables (c, p, i) to the Visible property. There might be an easier way with Switch, but this should do the job as well.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.

View solution in original post

5 REPLIES 5
FabianAckeret
Solution Sage
Solution Sage

@amyharkus86 

 

Is this what you'd like to achieve?

cpi.gif

 

I created this by using the following formula on Toggle1:

 

If(
    Self.Value && Toggle2.Value = false, 
    Set(c,true);
    Set(p,false);
    Set(i,false),
    Self.Value && Toggle2.Value,
    Set(c,true);
    Set(p,true);
    Set(i,false)
);

 

 

and this on Toggle2

 

If(
    Self.Value && Toggle1.Value = false, 
    Set(c,false);
    Set(p,true);
    Set(i,false),
    Self.Value && Toggle1.Value,
    Set(c,true);
    Set(p,true);
    Set(i,false)
);

 

 

I hope this helps. Please let me know.

 

Should this answer help you, please mark it as a solution.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.
WarrenBelz
Super User
Super User

Hi @amyharkus86 ,

Try

Set(p,Toggle1.Value);
Set(c,Toggle2.Value);
Set(i,false)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @WarrenBelz  your fist reply is accurate ish, i only want the visibly of these to change on button click as it then takes them to another view 

 

On toggle1 Oncheck i have this 

true & UpdateContext({varContractSub: "No"}); UpdateContext({varContractName:"Internal Transfer/Change Of Role & Contract Particulars"}); If(Toggle2.Value = true, UpdateContext({varContractName:"Internal Transfer/Change Of Role & Contract Particulars & Pay & Benefits"}))

on toggle 2 Oncheck i have this 

true & UpdateContext({varContractSub: "No"}); UpdateContext({varContractName:"Internal Transfer/Change Of Role & Pay & Benfits"}); If(Toggle1.Value = true, UpdateContext({varContractName:"Internal Transfer/Change Of Role & Contract Particulars & Pay & Benefits"}))

 On the button i have 'Next' on select i want to have if toggle one is selected to view 'C' fields, I have a bunch of required fields for c that are set visible = c 

same for toggle two but instead p 

 

i want to view both the fields in c and p if both toggles are true.

 

I dont want the change to happen on the toggle as visible on the submitted button based on these toggles, if they are both false then the submitted but is visable, if one of them is true the 'Next' button is instead visible.

 

So although the above works i dont want to make the change on the toggles. 

 

@amyharkus86 

 

In this case, you can use the following formula on your next button:

 

 

If(
    Toggle1.Value && Toggle2.Value = false,
    Set(c,true);Set(p,false);Set(i,false),
    If(
        Toggle2.Value && Toggle1.Value = false,
        Set(c,false);Set(p,true);Set(i,false),
        If(
            Toggle2.Value && Toggle1.Value,
            Set(c,true);Set(p,true);Set(i,false),
            Set(c,false);Set(p,false);Set(i,false)
        )
    )
)

 

 

Then, on all the fields that need to be visible/not visible, add the corresponding variables (c, p, i) to the Visible property. There might be an easier way with Switch, but this should do the job as well.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.

@amyharkus86 ,

Good that @FabianAckeret has solved this for you.
I have been offline for the last two days due to location.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,929)