Skip to main content
Known Participant
September 18, 2021
Answered

Clicking NO should not open the Print Box

  • September 18, 2021
  • 5 replies
  • 1193 views

SEE ATTACHED IMAGE

When you click "Print" a "Message" pops up saying "Did

you check the form" YES or NO. If you click YES the

Print Box pops up as it should. If you click NO the Message box

should close and the Print box should not pop up but it does. How do I stop it from opening when clicking NO?

This is the Javascript I am using now:

if (app.alert("Have you checked and saved the form?",2,2)==4);

 

ATTACHED IMAGE

 

 

This topic has been closed for replies.
Correct answer try67

I just tried that and it actually got rid of the RED X at the top left corner of the Message. However, now when I click SAVE the Message pops up without the RED X and then I click OK and the Save dialog box opens but if I click Cancel instead of Choose A Different Folder, the form then closes and then opens up again. What am I doing wrong?


What cancel button?

5 replies

try67
Community Expert
Community Expert
September 18, 2021

Did you add a separate command (most likely "Execute a menu item" - "File>Print..." one), after the Execute a JavaScript command? If so, remove it, and change your code to the following:

 

if (app.alert("Have you checked and saved the form?",2,2)==4) this.print();

sbc707Author
Known Participant
September 18, 2021

OMG that worked. Can I use the same code for "Save As" changing the "this.print" to "this.saveas" and deleteing the Save As in Execute a menu item?

 

I also want to do Clear Form when you click YES it clears the form and if you say NO it does not clear and the message box closes.

sbc707Author
Known Participant
September 18, 2021

This is what I am after which would make my day along with 4,000 police officers.

 

Save Form (Mouse Up)

 

When you click the “Save Form” button a Message box should popup and say:

 

“Save this form under Suspect name; LAST, First & Date”

                                                                                               YES     NO

 

When you click “YES” the “Save As” dialog box should open allowing you to save the document

When you click “NO” the Message box should close and the save as dialog box will NOT pop up.

-------------------------------------------------------------------------------------------------------------------------------

Clear Form (Mouse Up)

 

When you click the “Clear Form” button a Message box should popup and say:

 

“STOP!

DO NOT clear this form until you saved it under Suspect name; LAST, First & Date.

Do you want to clear this form?”

                                                                                               YES     NO

 

When you click “YES” the form should be cleared and the Message box should close.

When you click “NO” the Message box should close and the form will NOT be cleared.

Bernd Alheit
Community Expert
Community Expert
September 18, 2021

Where does you use the print command?

sbc707Author
Known Participant
September 18, 2021

The Print command is in a box at the top of the form. I am actually thinking of changing the YES/NO to just OK so when they click OK the print box opens or if it's the Save As then the Save As box opens. Much simpler.

Legend
September 18, 2021

Ah, there's the problem. Each action is separate, and one action can't stop the next. So you can do anything in your JavaScript and it won't stop the separate print action.


The solution is to lose the print action, and instead put a print JavaScript command into your script, run only if the user says Yes. (So, think in terms of "confirming print then printing" rather than "cancelling print").

sbc707Author
Known Participant
September 18, 2021

Sorry about that. Yes it is "Mouse UP"

sbc707Author
Known Participant
September 18, 2021

I am totally not familiar with how to do this. Is it possible you can change the code to what will work?

When the Message pops up clicking YES should open the Print box and it does just that okay.

If you click NO the Message still pops up when it should not, just the Message box should close.

Very much appreciated.

Legend
September 18, 2021

We need to understand what you are doing. How, in particular, is your code called? For example is it the "mouse up" action for a button you added?

 

People often focus on the lines of the code, but just as important is how the code is called. Something written for a validate action won't work on a calculate action. Something written for a mouse up action won't work on a DidPrint action. And so on.

Legend
September 18, 2021

Your code shows an alert box. But your code does nothing with the user's answer - yes or no.clearly, then, the response has no effect.  Nor does your code include a print request, we're only seeing half the story. (Tip: the WILL PRINT action means what it says. It WILL print, The action is not given a way to stop it)