Control print setting

Hi Guys,

 

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..

 

Thank you.

  • In reply to JEMT:

    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?".

  • In reply to Martin Dráb:

    apologize for what i do martin.

    ok.

    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

     

    Thanks

  • In reply to JEMT:

    I 'm probably failing to ask in the right way, because I still don't see the answer.
    You asked for help about how to get the caller form, so I wanted to know if you have no clue at all about how to do such things in AX, or if have some particular problem in this specific scenario. We need to know which topic we should explain to you.
    Now you're asking how to close a report, but you should formulate in a different way. You want to close the form (report viewer) in which the report is displayed; that's why I already explained how to close a form from code.
  • In reply to Martin Dráb:

    "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?


  • In reply to JEMT:

    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.

  • In reply to Martin Dráb:

    Thanks Martin.

    sorry martin i forgot to say that the RerpotRun (ObjetRun) should be close not the form.

    because after i click the "OK Button" in the SysPrintForm that form will close and print to printer.

    I' m having a hard time to close ALL Open ReportRun (ObjectRun).

    I hope you understand my situation.

    I appreciate your time and effort.

    Regards,
  • In reply to JEMT:

    I don't think you're right. ReportRun has no visualization; what you showed before was clearly the report viewer form.
    Imagine that you choose printing to a printer, a file or anything else except of screen. ReportRun will run, it will generate an output and nothing will be shown on screen. To show something on screen, you need a form and that's what the report viewer form does if you print to screen.
  • In reply to Martin Dráb:

    Now i understand ..

    i will get back to you after i tried what you said above.

    Thank you.
Related
Recommended