Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

How to save a form in a different file name?

Avatar

Level 9

Hello All,

I have a form which has 7 pages. I have 3 buttons which are for submitting PDF,XML and print button. I do not want to keep SaveAs button.

What I need : When the user completes all the required fields and clicks on SubmitAsPDF or SubmitAsXML then it will prompt the user to save the form in a different file name. After the user has saved the form in a different file name then it should submit the form to the required mail ID. How to best accomplish it ?

Thanks.

Bibhu.

8 Replies

Avatar

Level 10

Try:

app.execMenuItem("SaveAs");

in the mouseUp event.

Niall

Avatar

Level 9

Hello Niall,

Probably you did not get what am trying to say. As I have 3 buttons I do not want put another extra button. When the user clicks the SubmitAsXML and/or SubmitAsPDF button before saving the form in a different file name then it should prompt the user to save the form. But once the form is saved in a different file name and after that the user clicks any of the submit button it should able to submit the form without prompting the user to save it again .

Thanks.

Bibhu.

Avatar

Level 10

I wasn't suggesting another button. You could put the script in the mouseUp event of the submit button(s).

This would fire the save as each time the submit button is clicked.

If you want this to fire only once, then you would need a docReady event script to capture the existing file name and store this in a hidden field or global variable, for example:

currentName.value = event.target.documentFileName; 

Then you would wrap the saveAs script in an if statement, checking if the current name is the same as the name at docReady. If it is, then fire the saveAs script.

Niall

Avatar

Level 9

Hello Niall,

Thanks for the help. I used a hidden field whose name is "CurrentFileName" then in the docReady event of this hidden field I used the following script.

this.rawValue = event.target.documentFileName;

Then in the mouseUp event of the submit button I used the follwing script.

if(form1.Page1.CurrentFileName.rawValue == event.target.documentFileName)
                      {
                         app.alert("Please save this form in a different file name before submitting !");
                         app.execMenuItem("SaveAs");
                      }

But problem is : As the file is saved in a different name the script fires again and again if we click the submit button prompting the user to save the form in a different file name , but the user has already saved it in different file name .How to get rid of it ?

Thanks.

Bibhu.

Avatar

Level 10

You need to compare the current file name with the name the form has initially.

var CurrentName = event.target.documentFileName;

var CheckName = "MyForm.pdf";

if (CurrentName == CheckName)

     {

     app.alert("Please save this form in a different file name before submitting !");

     app.execMenuItem("SaveAs");

     }

else

     {

     // Script when File already has been renamed

     }    

Avatar

Level 9

Hello Radzmar,

As we are doing SaveAs operation , the file name is always different after we saved it. Lets say the form has name "Form1" before saving it. We click the submit button, it asked for to save it and we saved it as "Form2".As the current file name is the same as before : Form1. So it would prompt the user again to save it.As we are not overwriting the form name here. In case we are doing just Save operation instead of SaveAs then your script might work.My headache is how to track if the user has saved the form in a different file name ?

Thanks.

Bibhu.

Avatar

Level 10

Hi,

I would only have expected the docReady event to fire once, when the form is opened. The script in the textfield should then record the initial name of the form.

Here is a sample that seems to work as intended: https://acrobat.com/#d=YmbNoXHnRSyepAIm-lXQQg

Good luck,

Niall

Avatar

Level 9

Hello Niall,

Thanks for the form. But I was exactly doing the same thing , still it was not working. I found that I kept on testing it in the Preview PDF instead of the actual form. When I tested it in the actual form , it worked. I am such a fool . Anyway , Thanks.

Bibhu.