4 Replies Latest reply on Sep 25, 2009 12:23 AM by Judith81

    Prompt for a new file name on first save

    Judith81

      I’m creating a form with 15 pages. The user might want to fill out the form several times with different content. So I’m looking for a solution where the user is asked to give a new name when s/he saves the PDF file for the first time. So the original empty form is still available for the next case.

      In Word I would create a template, so a document created based on this template has no name unless the user specifies one. I.e. when the user clicks on the save button for the first time s/he gets a Save as dialog.

      In Adobe I did not find a similar thing. I tried to add a preSave event asking the user whether s/he wants to give a new name, however then the user will be asked each time to give a name, not only the first time. Maybe I could check the filename, however I wonder whether there is an easier solution.

      Any help is greatly appreciated.

        • 1. Re: Prompt for a new file name on first save
          $Nith$ Level 4

          use export DataObject method for your requirement.

           

          See the Javascript documetation for more details.

           

          Nith    

          • 2. Re: Prompt for a new file name on first save
            Judith81 Level 1

            Thank you, Nith, for looking at my problem.

             

            Do you mean the scripting mehtod xfa.host.exportData?

            As far as I understood, this can be used to export the data, but not to save the whole file as PDF.

             

            My current solution looks like follows. I'm using the docReady event, to ask the user whether s/he wants to save under the same name or not

            ServiceProcurementNotice::docReady - (JavaScript, client)

            var

             

             

             

            myDoc = event.target;

             

            try

             

             

             

            {var userSave = xfa.host.messageBox("Do you want to save changes to " + myDoc.documentFileName,"Save",2,3);

             

             

            if ( userSave == 3 )

            {

            app.execMenuItem("SaveAs");

            }

             

            else

            {

            }

            }

            catch

             

             

             

            (err){app.alert("Exception in save: "+err);}

             

             

            This solution has the disadvantage, that the message pops up each time the pdf file is opened. I would prefer the message to come up only upon first usage, i.e. when all fields are still empty.

             

            Judith

             

            • 3. Re: Prompt for a new file name on first save
              $Nith$ Level 4

              Why don you keep a control info in a hidden text field?

               

              I have modified you code a little. (see the lines in red color)

               

              If still not working, post your form to this forum to have a look at it.

               

              Nith

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

               

               

              ServiceProcurementNotice::docReady - (JavaScript, client)

               

              var

               

               

               

              myDoc = event.target;

               

               

              var saveFlag = true;

               

               

               

              try

               

               

               

              {

              var userSave;

              if(saveFlag)

              {

                   userSave = xfa.host.messageBox("Do you want to save changes to " + myDoc.documentFileName,"Save",2,3);

              }

               

              if ( userSave == 3 )

               

              {

              app.execMenuItem("SaveAs");

               

              saveFlag = false;

              txtHiddenSaveFlag.rawValue = "false";       // If you want to keep this info even after closing the form

               

              }

               

               

               

              else

              {

              }

              }

              catch

               

               

               

              (err){app.alert("Exception in save: "+err);}

               

               

              if ( userSave == 3 )

               

              {

              app.execMenuItem("SaveAs");

               

              saveFlag = false;

              txtHiddenSaveFlag.rawValue = "false";       // If you want to keep this info even after closing the form

               

              }

               

               

               

              else

              {

              }

              }

              catch

               

               

               

              (err){app.alert("Exception in save: "+err);}

               

              if ( userSave == 3 )

               

              {

              app.execMenuItem("SaveAs");

               

              saveFlag = false;

              txtHiddenSaveFlag.rawValue = "false";       // If you want to keep this info even after closing the form

               

              }

               

               

               

              else

              {

              }

              }

              catch

               

               

               

              (err){app.alert("Exception in save: "+err);}

               

              • 4. Re: Prompt for a new file name on first save
                Judith81 Level 1

                Thank you, Nith, for looking again at my problem.

                Your proposal works.

                 

                Have a nice weekend,

                Judith