this Question is continuation of this thread How to disable print button when report already printed.
As image shows above.
What i want to happen is upon clicking the "OK" button in the 3rd image to print the reports, then it will tells report is printed and automatic close the 1st and 2nd image/window. Please view the link above to understand.
hoping your quick response..
A trickier part may be getting a reference to the form. I wonder if you have already tried it and got into a problem, or you don't even know how to get a caller form in general. - can you please help me on this?
i need to learn a lot things in ax.. please understand..
There is not much to say about it; simply call the method. Like this: formRun.close();
When I said "I wonder if you have already tried it and got into a problem, or you don't even know how to get a caller form in general", you merely replied "can you please help me on this?", but you didn't even told of those two options are you dealing with. If you need out help, please realize that you must do your part as well and explain what you need from us.
Also note that merely shouting without providing any information won't help anybody to understand your problem; that's why I deleted your replies that contained only "anyone?".
apologize for what i do martin.
I Have customized table so i need to create if user click on Print Button for taking print it will give print only one time and then disable for some users. It means higher authority had access to grant the user to reprint, i will customize that to.
- I am done with Adding a 'printed' flag in my main data record table of my report, and once my report is already printed, that 'printed' flag is updated to true. The button is already disable.
but apparently there's a problem, not totally big problem. i want to close the print preview right after the user print to the printer.
If we can open a report through X++ then i want to close that in the same manner .
Please let me know how could I do this
"A trickier part may be getting a reference to the form." - here I am having a difficulty
"I wonder if you have already tried it and got into a problem" - yes! that's why i am still asking here.
all i want is to close all the OPEN REPORT Preview or Print Preview (what ever it calls it) after i print to the printer. I do not know how close MenuItem "OUTPUT" using the form SysPrintForm.
did i answer your question martin?
All right, let's start from basics. Forms are objects (instances of FormRun) class and you can use methods for manipulating them. For instance, you can use close() method to close them.
A trivial example is closing the current forum. You can simply refer to the current form by "this" reference from form-level methods (and "element" reference from method on datasources and controls), therefore you can simply call this.close(). I encourage you to try it by yourself.
If you want to work with another form, you must get a reference to it (which is true for all other objects in object-oriented programming). How to do it depends on situation.
The most common case is getting a reference to the caller form, which can be obtained from arguments used for calling the current form: this.args().caller(). Caller is a reference to the caller object, therefore if it was a form, it's a FormRun instance of the caller form. This is usually used for refreshing the form or passing data; closing is a bit different case because you usually you can't close the caller form before closing the child form (unless it's detached).
In other case, you may want to open a form from code and then close it from code as well. You'll create a FormRun instance (classFactory.formRunClass()) and then store the reference for later, when you'll again call close() method on it.
Therefore if you want to close the report viewer form, the first thing you must do is analyzing how you can get a reference to it.
the caller is PrintJobSettings.
but PrintJobSettings has no close method..
See below image.
aside from PrintJobSettings. the other caller is SysSetupFormRun.
this the only thing left behind, please martin help me.