• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Save form help

Explorer ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

ok. I am apparently very confused or something has changed since the tutorials were made. I am having difficulty getting the save button action code to work, and have several questions.

1. I want to force the user to save the form under a different file name and the code samples do not work that I have tried:

// Split Path into an array so it is easy to work with
var aMyPath = this.path.split("/");

// Remove old file name
aMyPath.pop();

// Add new file name
aMyPath.push("NewFileName.pdf");

// Put path back together and save
this.saveAs(aMyPath.join("/"));

This does not work as run a JavaScript after the Save As menu item execution action is first performed. The same file name is displayed waiting for the save button or cancel button to be pressed.

I have this as the last line of code to insure the original form is not overwritten:

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

That part works.

I have also tried the following code and it doesn't work and I really don't understand it:

var mySaveAs = app.trustedFunction(
function(oDoc,cPath,cFlName)
{
app.beginPriv();
// Ensure path has trailing "/"
cPath = cPath.replace(/([^/])$/, "$1/");
try{
oDoc.saveAs(cPath + cFlName);
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
}
);

I am apparently missing something somewhere.

 

What I want to do is save the filled-in form as a new document with a different filename and preserve the original document without changes. The current location is fine. I'm not concerned about the file path. Currently, the save as dialog pops up and asks for the save location. Click on the highlighted folder (a step I would like to eliminate) and then has the current filename in the filename field highlighted. The above code doesn't affect that.

 

2. I can't make sense of all the information about trusted files. It would be really nice to be able to create that new file name dynamically from the name and month fields. These are individual users that are not on any network or anything. I have no access to their individual devices. The other posts about this are unclear to me at my current level of knowledge.

 

3. If I flatten the file as part of the save as string of events, it makes the original file read only, which I don't want. The original form needs to remain intact while the newly saved form cannot be edited or the layout changed, etc. 

 

4. Can the original form be cleared either after it is saved to the new file, or when the file is opened the next time? I have some fields that already read-only and need to stay that way, so doing a bulk removal of the read-only is not an option.

 

Any help would be greatly appreciated. I have spent days googling this stuff and browsing these forums.

 

TOPICS
How to , JavaScript , PDF forms

Views

288

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
LEGEND ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

The security restrictions are very specific. Naturally, you can't just send someone a file that silently saves. This could be used by hackers to do untold mischief. 
so, you can only do this if you have full access to the computer and can create scripts in the trusted file location. Furthermore, you must created a Trusted function for the parts that are going to need special privileges. 
Are you looking it the JavaScript console? It should be telling you this, in its way. 

Votes

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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

I don’t know how to use the console. I’m just testing the code in the form
using preview in form prep mode.

Can I do any of those things I asked about?
--
Chaplain Derek Godfrey

Votes

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
Community Expert ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

LATEST

This is all possible, if you can install a script file on the local computer of each user.

 

If the tutorials on this subject are too complicated for your level of knowledge I recommend hiring a professional to set it up for you.

Votes

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