How to overwrite CloseOK of a standard form

D365
I have a std Form. Among many other things , it has two local variables and CloseOK method. In closeOK it launches class A and passes into it its two local variables

I need to call in CloseOK my class B (instead of A) and pass the same local variables.
I’m stuck as I don’t understand

  1. how I can bypass the standard call to CloseOK so that that Class A is not called?
  2. How I can access those local variables of the form if there are no parm methods?
    Please help (

You can’t use extensions to skip existing code (unless the code explicitly allows it). Therefore your design is wrong; it can’t be implemented.

You need to think about a different design. For example, check if the class instantiation can’t be extended. Or maybe you need to create an extensibility request.

Regarding form variables (not local method variables!), you can easily access them by name in form extension classes.

Thank you Martin.
What about hiding a std OK button in form extension and adding a new one MyBtn instead and in its onClicked eventHandler running my code? Would that be ok from the design perspective?

Yes, it may be an option. It depends on how the form is implemented and used.