Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

Prompt for a new file name on first save

Avatar

Level 1

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 Accepted Solution

Avatar

Correct answer by
Level 10

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);}

View solution in original post

4 Replies

Avatar

Level 10

use export DataObject method for your requirement.

See the Javascript documetation for more details.

Nith    

Avatar

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

Avatar

Correct answer by
Level 10

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);}

Avatar

Level 1

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

Your proposal works.

Have a nice weekend,

Judith