Temporarily stop events from firing in customization

We have a customization that could cause a loop do to an After Field Change Event that involves the same field. Is there a C# statement to Stop (disable) and Start (enable) events that we can use to avoid this potential loop?

There are a lot of things that you can do in C# to validate whether or not something should happen or not. You will probably need to give more specifics for anyone to help you though. “Something in a loop” is not a special property that exists that you can key off of. You will have to run if statements to validate on some condition in the data.

1 Like

I’ve had something that sounds similar, when I wanted to update a certain field programatically but also respond when it was manually updated. I added some script-level bool variables. Then your event handler is something like:

if(doTheCode){
   doTheCode = false;
   TheCode();
}

So if TheCode() triggers the same event, it won’t be run a second time. You set the variable to true somewhere else, depending on what you’re trying to do.