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 / How to Stop Recursion ...
Power Apps
Unanswered

How to Stop Recursion on SQL Based Canvas App Gallery Row having two toggles updating values of each other

(0) ShareShare
ReportReport
Posted on by 6

Hi All,

 

I have a canvas app directly connected to SQL Server table, Canvas App Gallery's data source is the SQL Table.

In a row of gallery I have 2 toggles against 2 fields in table, I have used patch function to update the values of both fields on change of both toggles and code on each toggle change is updating another field value, which triggers onchange code written in Another toggle which updates the value of another field.

 

This is creating infinite loop, do we any anything to check recursion's depth in Canvas App? same as we have in Dynamics CRM Plugins, where we can check depth and break the infinite loop. 

 

Thank you

Neeraj

1.jpg
Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Can you try to write your code on OnCheck and OnUnCheck properties of the toggle. Ideally changing one toggle shouldn't affect another toggle.

  • ambitiousneeraj Profile Picture
    6 on at

    But, I need to change 2nd toggle value on change of 1st toggle, and also need to change 1st toggle value if 2nd toggle value, which is creating a loop.

     

    And I want to break the loop if recursion depth is more than 1, I can make a global variable for depth, but it has to be reset every time when update toggle value manually, when toggle value is changed by code automatically depth variable value must not be reset.  

  • ambitiousneeraj Profile Picture
    6 on at

    Can anyone help on the solution for problem?

  • Ajinder31 Profile Picture
    530 on at

    Hi @ambitiousneeraj , I think you can Patch based on some condition and not onChange event of toggle. Something like set available true based on scenario in your case and only call Patch when variable is true and set it false once action is performed. 

    If this doesn't solve the issue, please share some code references to how you're implementing it in your side. Thanks.

  • ambitiousneeraj Profile Picture
    6 on at

    @Ajinder31 I need to save data immediately as soon as toggle value changes, not on submit button, if it is submit button then I can handle it, the solution you suggested is more like validation before saving.

     

    If you have any solution for Save on toggle change, please suggest..

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard