Form won't close because I called *.wait()

I’m running this code to call another form, and sometimes my forms won’t close. I’m pretty sure it’s because it’s “waiting”, and I have to Ctrl+Alt+Del to close AX. What’s the proper way to do this and/or does anybody see what I’m doing wrong?

public Object dialog()

{

FormRun returnGroupInspectionForm;

Args args = new Args();

Object object;

;

args.name(formstr(ReturnGroupInspection));

args.caller(this);

args.record(salesTable);

returnGroupInspectionForm = classfactory.formRunClass(args);

returnGroupInspectionForm.init();

returnGroupInspectionForm.run();

returnGroupInspectionForm.wait();

return returnGroupInspectionForm;

}

Are you using a RunBase class? Where is the dialog method residing, in the class or in a form?

Yes. My code is being called from a class that extends RunBaseBatch. I really hope you know how to fix this, it’s been driving me crazy.

So, let me understand what you want to do. You have created a form, added some controls I suppose, and then you want this form to act as a RunBase dialog, is this correct? If not, can you explain me exactly what you want to achieve?

This is essentially what I want to do. I have a class that calls a custom form I created to collect a bit of information from users. When the users click “OK” on the form, the class is supposed to take the information from the form and process it. I have a menu button on the parent form that calls the class, which in turn calls the form via the dialog. Sometimes either the child or parent form will not close, and I have to Ctrl+Alt+Del out of it.

Yes, this is because you need to treat the child form in a special way. Please take a look at the Tutorial_RunbaseForm class, and also the Tutorial_RunbaseForm form, follow the same approach in your stuff and you will be able to close the form.

Hope this helps.

I see the difference seems to be:
DialogRunbase dialog = Dialog::newFormnameRunbase(formstr(tutorial_RunbaseForm),this);

How would I pass a record to the form though to initialize it. In my code above, I’m using the args to pass a specific sales table record. My code is called from a button on the Form\SalesTable, so I’m just passing the current sales order.

Would I do something on the form such as:
salesTable = element.args().caller().parmSalesTable();

Or should is there a way to pass it from the class?

After the RunBase class is instantiated (normally on the main method or a newConstructor), you should set the buffer like:

inventTable = args.record();

tutorial_RunbaseForm.parmInventTable(inventTable);

the form constains a reference to the Runbase class so you can use that reference to get the selected buffer.

This is much easier than what I was doing. How would you recommend passing back the rows entered into a temporary datasource then? Or returning data back to the class? Just the parm methods on the class? Do you pass the entire datasource?

Under CalCode of the Form - Close I use this.

CloseIt.RUN();

You could use a Map:

new

Map(typeName2Type(extendedtypestr(recId)), Types::Record);

then use the Map.Pack method on the pack method of the RunBase class. Take a look at BOMChangeItem class.

I tried this method and it works great when I click “OK”. In my closeOK method, I call my tutorial_runbaseform.parmMethods() to pass the data.

If I run it in batch however, my variables aren’t getting passed to the parm methods. Any idea why? I have on my form this method:

//AOSRunMode::Client

RunBase runBase()

{

return tutorial_runbaseForm;

}

What variables to do you on your RunBase class, classDeclaration method, CurrentList macro? Have you added all your variables there?

I have the currentlist macro, classDec, etc. If I click “OK” it works fine and all of my code in the “CloseOK” method is run. That is where I call my class’s parm methods.

When I switch to the batch tab and check the batch to run in batch, the code in the “CloseOK” still runs, but somehow the variables aren’t getting passed. I created a parmInt and parmBoolean to test with some infologs and they do get passed when it’s not in batch. But when I run it in batch, those variables aren’t passed.

Are there any more methods that need to be added to the form or on the class to properly fit the framework?

Are you instantiating the RunBase class object on the server? For this you should have your construct method with server keyword.

My class has “server static” for the construct method. The class itself has the property “RunOn: CalledFrom”. The menu item that calls the class has “RunOn: CalledFrom” as well. It’s very strange. I changed the menu item to “RunOn: Server” and then I wasn’t able to pass the salesTable record to the form and it was worse, so I put it back.

Not sure what could be the issue, please feel free to send me your code at fabnor@dynaxti.com, we can solve this offline.