web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Odd behavior in Toggle...
Power Apps
Suggested Answer

Odd behavior in Toggle control

(1) ShareShare
ReportReport
Posted on by 145
I have a toggle control that I am using to set an Is Active flag for a record in the database. I have a Power Automate Flow that calls a stored procedure that updates the value in my SQL Server DB. I have set the Default value of the Toggle to be the bit value in the database via a Lookup
 
LookUp('VC.BusinessEntities',BusinessEntityId=galBusinessEntity.Selected.BusinessEntityId).IsActive
This is all working well so far.
 
I have the OnChange property of the toggle set to run my flow:
 
UpdateContext(
    {
        OnChangeResult: VC_BusinessEntityIsActive.Run(
            galBusinessEntity.Selected.BusinessEntityId,
            tglIsActive_CarrierEdit_1.Value,
            User().FullName
        )
    }
);
 If(
        OnChangeResult.statuscode = "200",
        Notify(
            "Save Successful",
            NotificationType.Success,
            5000
        ),
        Notify(
            OnChangeResult.errormessage,
            NotificationType.Error,
            5000
        )
    );
Again, so far so good. The odd behavior is that the first time I access my edit screen where this control lives it fires the flow even though I haven't selected or changed the value of the control. Is this the intended behavior? How do I configure the control so that this doesn't happen?
Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,862 Moderator on at
    Does the toggle have a default value?
    Also, you could consider using the new toggle control which has an OnCheck and OnUncheck property.
  • Suggested answer
    jpespena Profile Picture
    335 on at
    Hi,
     
    I've experienced the same where accessing forms from View mode to Edit mode triggers the OnChange property of components like dropdown and toggles. If you want to keep your code in the OnChange property, you can add a validation that check if the value of the toggle is the same as the selected record, for example if you are coming from a gallery to the edit screen:
    If(
        Gallery.Selected.ToggleFieldValue <> Self.Value,
        UpdateContext(
        {
            OnChangeResult: VC_BusinessEntityIsActive.Run(
                galBusinessEntity.Selected.BusinessEntityId,
                tglIsActive_CarrierEdit_1.Value,
                User().FullName
            )
        }
    );
     If(
            OnChangeResult.statuscode = "200",
            Notify(
                "Save Successful",
                NotificationType.Success,
                5000
            ),
            Notify(
                OnChangeResult.errormessage,
                NotificationType.Error,
                5000
            )
        );
    )
    This code looks if the toggle value is not equal to the current value of the selected item in the gallery, then it perform the flow run.
     

    If my post helped resolve your issue, please click Accept as Solution—this helps others find it more easily and marks the item as closed. If you found this or my previous reply helpful, a Like would also be appreciated!

  • tjestesjr Profile Picture
    145 on at
    I moved the following code from the OnChange property to the  OnCheck and OnUncheck properties. But I get the same result, which is that the flow is run automatically.
    UpdateContext(
        {
            OnChangeResult: VC_BusinessEntityIsActive.Run(
                galBusinessEntity.Selected.BusinessEntityId,
                tglIsActive_CarrierEdit_1.Value,
                User().FullName
            )
        }
    );
     If(
            OnChangeResult.statuscode = "200",
            Notify(
                "Save Successful",
                NotificationType.Success,
                5000
            ),
            Notify(
                OnChangeResult.errormessage,
                NotificationType.Error,
                5000
            )
        );
     
  • tjestesjr Profile Picture
    145 on at
    I implemented the If statement as @jpespena suggested and the toggle now behaves as expected.
  • jpespena Profile Picture
    335 on at
    Hi,
     
    If my post helped resolve your issue, please click Accept as Solution—this helps others find it more easily and marks the item as closed. If you found this or my previous reply helpful, a Like would also be appreciated!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard