Notifications
Announcements
No record found.
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
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.
There is a class called by form X to call form Y.
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.
Please look into the product documentation, too: docs.microsoft.com/.../how-to-refresh-the-calling-form
I got your idea and I already have this docs page. How can I fire my code with form Y close() event?
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.
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?
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.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2