cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julien2
Post Prodigy
Post Prodigy

Toggle switches automatically based on a condition

Hello,

I have a PowerApps app connected to an SP List, and I want to switch On the toggle based on a column text value.

The condition should check if FirstMangSign (Single Line of Text) equals Signed, then the toggle should be switched automatically to On, and if the field was not filled to Signed then the toggle should be switched to Off.

Besides, I want to hide this toggle so the user will not be able to see it.

I have tried to implement the following function check property of the toggle:

Set(
    vNotSigned,
        IsBlank(
                First(
                        Filter(
                                'Purchase Order I', 
                                ID = SelectedReport.ID && 
                                FirstMangSign= "Signed"
                            )
                    )
                )
);

If(!vNotSigned, UpdateContext({Checked: true}),UpdateContext({Checked: false}))

And I have set the Default value of the toggle to Checked. (Which is the value that I have initialized)

Unfortunately, nothing happens and the toggle is always showing Off knowing that the SelectedReport ID in SP list the FirstMangSign column is signed.

Can please someone explains in detail and provide an example to achieve the above scenario?

Any help will be greatly appreciated.

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Julien2 ,

Where do you put your Set formula? Do you type your Set function within OnCheck property of Toggle control?

 

Currently, there is an known issue with the OnCheck property of the Toggle control -- Toggle.OnCheck, .OnUncheck, and OnChange fires when its value changes, regardless of user interaction. Please check the following thread for more details:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Bug-When-using-Toggle-control-to-patch-a-col...

 

So please do not put your Set formula within the OnCheck property of Toggle control. Based on the needs that you mentioned, I think it is not necessary to initialize a variable to achieve your needs.

Please consider set the Default property of the Toggle control to following:

If(
   IsBlank(
           LookUp('Purchase Order I', ID = SelectedReport.ID && FirstMangSign = "Signed")
   ),
   false,
   true
)

 

In addition, you could also consider add a Checkbox control in your app to achieve your needs instead of this Toggle control.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @Julien2 ,

Where do you put your Set formula? Do you type your Set function within OnCheck property of Toggle control?

 

Currently, there is an known issue with the OnCheck property of the Toggle control -- Toggle.OnCheck, .OnUncheck, and OnChange fires when its value changes, regardless of user interaction. Please check the following thread for more details:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Bug-When-using-Toggle-control-to-patch-a-col...

 

So please do not put your Set formula within the OnCheck property of Toggle control. Based on the needs that you mentioned, I think it is not necessary to initialize a variable to achieve your needs.

Please consider set the Default property of the Toggle control to following:

If(
   IsBlank(
           LookUp('Purchase Order I', ID = SelectedReport.ID && FirstMangSign = "Signed")
   ),
   false,
   true
)

 

In addition, you could also consider add a Checkbox control in your app to achieve your needs instead of this Toggle control.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hello @v-xida-msft ,
Thanks for your advice. Currently, The toggle works as expected.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,319)