In a form Y close() event, I want to refresh a form X.
Form X is not the parent form of form Y.
How can I accomplish this?
Thanks in advance.
*This post is locked for comments
In a form Y close() event, I want to refresh a form X.
Form X is not the parent form of form Y.
How can I accomplish this?
Thanks in advance.
*This post is locked for comments
I assume the main method of the handler class is called from form X.
1) add new variable FormRun formX in your handler class. And add method parmFormX for getting and setting that variable
2) in your main method, add this line of code: handler.parmFormX(args.caller());
3) in openForm method add this line of code: args.caller(this);
Now in your form Y you can reach your handler class like this:
MyHandlerClass handler = args.caller():
And you can reach form x like this:
FormRun formX = handler.parmFormX();
Now you can call any methods of form X from form Y by using this formX variable.
Here is my Handler class main method:
static void main(Args args) { MyHandlerClass handler; Table1 ParentTable; Table2 ChildTable1; Table3 ChildTable2; if (args && args.record()) { switch (args.menuItemName()) { case (menuitemactionstr(MenuItem1)): ParentTable = args.record(); handler = MyHandlerClass::construct(); handler.parmId(ParentTable.Id); handler.run(); break; } } }
I open form Y with the following class method:
void openForm() { FormRun formRun; Args args = new Args(); ; args.name(formstr(FormY)); args.record(ParentTable); formRun = ClassFactory.formRunClass(args); formRun.init(); formRun.run(); formRun.wait(); }
Now I want to refresh form X when form Y get closed.
You already told me to do it within my class.
How can I do it?
There is a code sample for this exact case in the doc page. So that is how you fire it.
If it's a standard form, you have to hook into the OnClosing event handler instead of using the closeOk method that is in the code sample. In the event you have FormRun of form Y in variable called sender.
sender.caller() returns the caller. You have to have either form X as the caller, or have a method in the caller that gives you the FormRun of form X. Then you can call the refresh of the FormRun of form X.
This is as much as I can help with your general level question. Since I know nothing about your forms and classes I can't give more specific help.
I got your idea and I already have this docs page. How can I fire my code with form Y close() event?
Please look into the product documentation, too: docs.microsoft.com/.../how-to-refresh-the-calling-form
Then you should be able to enhance this class to include reference to the caller form. Maybe it already exists?
For example if it's called through a menu item, the caller can be present in args.caller().
Can you proceed with this info? If not, please provide your code.
There is a class called by form X to call form Y.
You have to have some kind of link between these forms. Basically you have to be able to pass the FormRun instance of your form X to form Y. Otherwise you can't call the refresh.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156