Constructing a form from your X++ code
When you construct a form from your X++ code, you must use the system classes.
Your code lines should look similar to the following
X++:
form = ClassFactory.FormRunClass(formstr(CustTable));
form.init();
form.run();
ClassFactory is an object of the class xClassFactory that holds the method FormRunClass that returns a new FormRun object.
The idea of using this indirection is to make it possible to inherit the FormRun class and override selected methods to change the behavior of the form executor. Subsequently, you can have all forms in the system executed with the new class instead of the ordinary FormRun by supplying the inherited class in the FormRunClass() method.
The system constructs all forms activated from the Application Object Tree using the xClassFactory.