When running the 'ProjTableCreate' Form from Code, I am not getting the same behavior as if I were to run it from the 'ProjTableCreateSubproject' display menu item.
Code:
ProjTable projTable = ProjTable::find('P400011');
FormRun formRun;
Args args = new Args();
;
args.name(formstr(ProjTableCreate));
args.parmEnumType(enumNum(ProjTableCreateLevel));
args.parmEnum(ProjTableCreateLevel::Subproject);
args.record(ProjTable);
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
if (!formRun.closed())
formrun.wait(true);
This results in:
If this were run correctly, it would look like this:
The project ID would show a new Subproject ID rather than just the first project in the Project Table.
In debugging, I can tell that when running through code it is not hitting some of the 'ProjTable' data source methods but I can't figure out why.
EDIT:
I am wanting to run this in code so I can use:
if (!formRun.closed())
formrun.wait(true);
This forces the user to deal with the form that popped up and prevents them from going to other forms. If there was a way to do this while using the standard menu item, I am fully open to that.