Highlighted

DocClose MessageBox returns

Avatar

Guest

08-01-2009

I have a dynamic form that I've created with a message at the end reminding the customer to save a copy for their records. What I'm not sure how to do, is have the user go back to the form if they click cancel. Here's my code for the docclose event:



xfa.host.messageBox("Did you submit your order and save a copy for your records?",2,2)



After the message comes up, the document closes when either option is clicked. How do I get it to go back to the form with the data still filled in, so they can do the options I mentioned above? (Save/submit)

Replies

Highlighted

pguerett

08-01-2009

Instead of using a message Box use an app.response where it will return what the user selected. Then you can test it with an if statement and take the appropriate action.
Highlighted

Avatar

Guest

08-01-2009

I'm still learning mode, and I'm not sure where I would put the app.response? I had the messagebox at the root in the docclose event. Would I still use the docclose? Can you give me an example of code for the app.response?
Highlighted

pguerett

08-01-2009

var cResponse = app.response({

cQuestion: "Did you submit your order and save a copy for your records?",

cTitle: "This is the title of the box.",

cDefault: "Yes",

cLabel: "Your answer: "

});

if (cResponse != "Yes"){

//Force the user to save the doc

app.alert("Saving the document for your records!");

app.execMenuItem("SaveAs")

}
Highlighted

Avatar

Guest

08-01-2009

I tried putting that code in on a test form and it does give me the boxes that it was suppose to. But it still gives me the same situation, when I type no or click cancel, the form is still gone and I can't do anything. It also doesn't prompt to save or submit the form. I did the code in the same place, docclose. Am I just entering the code in the wrong event?
Highlighted

Avatar

Guest

08-01-2009

I tried the code on a button and I with that, was able to get the prompts to save as with the answer of "no" or by clicking cancel. But it didn't give me the option to close the form if I click ok?



Is the only way to create this code with a button? Or is there a way to give these messages when closing the document?
Highlighted

pguerett

08-01-2009

If you put a button on your form that will do the close for you then you can control it as above. If you allow the user to File/Close then you cannot control it (as far as I know anyways).



That would be no different than hit the x at the top right of the app.



The preSave will only fire if you do a saveAs so that woudl not be a viable solution.
Highlighted

Avatar

Guest

08-01-2009

I can definitely see how that would be. Thank you for everything. That helped me out a lot. Do you happen to know how I can get the application to close under the "yes" option of the code you supplied?
Highlighted

Avatar

Guest

09-01-2009

I think I'm still missing something. I'm using this code and it won't work. Would I just use an "else" statement after the "if" statement such as:



var cResponse = app.response({

cQuestion: "Did you submit your order and save a copy for your records?",

cTitle: "This is the title of the box.",

cDefault: "Yes",

cLabel: "Your answer: "

});

if (cResponse != "Yes"){

//Force the user to save the doc

app.alert("Saving the document for your records!");

app.execMenuItem("SaveAs")



else app.execMenuItem("Close")