Save button issues

Explorer ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

I'm still struggling with my save button basic functions (I think). While it actually works, the console is giving me an error:

 

// Filename Warning Dialog
app.alert({
cMsg: "Please rename the file before saving. The suggested format is: Initial-Lastname_Month-Year_Service_Form.",
cTitle: "FILENAME WARNING",
nIcon: 1, nType: 0
});

app.execMenuItem("SaveAs");

this.saveAs({cPath:cMyPath, bPromptToOverwrite:true});

 

Exception in line 10 of function top_level, script AcroForm:ButtonSave:Annot1:MouseUp:Action2

It sometimes gives me the error that cMyPath is undefined.

 

I'm going to add this to the JS (Action2) that goes before it. But I have other issues with that script I am working on (some in a different thread).

TOPICS
General troubleshooting , How to , JavaScript , PDF forms

Views

43

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Aug 05, 2022 Aug 05, 2022

You don't need it for that. The built-in Save As dialog will prompt the user to confirm overwriting if they select an existing file. And the error message is because you can't use saveAs in that way. You need to remove that line entirely.

Likes

Translate

Translate
Explorer ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Exception in line 10 of function top_level, script AcroForm:ButtonSave:Annot1:MouseUp:Action2

ReferenceError: cMyPath is not defined
10:AcroForm:ButtonSave:Annot1:MouseUp:Action2Exception in line 10 of function top_level, script AcroForm:ButtonSave:Annot1:MouseUp:Action2

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Make sure that cMyPath is defined.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

You can't specify the cPath parameter if you're not running the code from a privileged context.

Also, as mentioned, you didn't define the cMyPath you're using for it.

You should remove the saveAs command entirely, as a matter of fact. The execMenuItem command will open the Save As dialog, where the user should enter the file name you've presented to them.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

I only have this.saveAs({cPath:cMyPath, bPromptToOverwrite:true}); in order to do the prompt to overwrite part, but I'm not sure how to make it work with just that part of the code? I tried but didn't get it right apparently. Can I do that without the path stuff? Just one more safety measure to prevent an accidental overwrite.

I am also occasionally getting this error:

NotAllowedError: Security settings prevent access to this property or method.
Doc.saveAs:10:AcroForm:ButtonSave:Annot1:MouseUp:Action2

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

You don't need it for that. The built-in Save As dialog will prompt the user to confirm overwriting if they select an existing file. And the error message is because you can't use saveAs in that way. You need to remove that line entirely.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

LATEST

Ok. Thanks. Once I thought about it some more, I realized that is probably what you were getting at.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines