Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Save As - Not Allowed Security Error

Jo_2005
Level 3
Level 3

Hello,

I have a script to save a livecycle form with a predefined path and file name.

However there is a Not allowed Error: Security settings prevent access to this property or method.

I am not sure why the security error is still there when a trusted function is used.

Can someone please provide some assistance with the script to advise where it could be going wrong?

mySaveAs

= app.trustPropagatorFunction(function(doc,path)

{

app.beginPriv();

doc.saveAs(path);

app.endPriv();

})

myTrustedSpecialTaskFunc

= app.trustedFunction(function(doc,path)

{

// Privileged and/or non-privileged code above

app.beginPriv();

mySaveAs(doc

,path);

app.endPriv();

// Privileged and/or non-privileged code below

});

myTrustedSpecialTaskFunc(

this, "/c/temp/Leave Application" + Applicants_Name.rawValue + ".pdf");

Any help will be greatly appreciated.

6 Replies
Reena_Kannan
Level 1
Level 1

http://forums.adobe.com/people/Niall%20O'Donovan

Hello Jo,

I have a referred to a Post by Niall O'Donovan in a Prior Post similar to yours,

see if this resolves your Issue.

================================================

You don't need this trusted function. It allows a form to access properties such as the login name, etc.

// folder level JavaScript to allow access to the identity object properties

trustedIdentity = app.trustedFunction( function (sProperty)

{

var iProperty = "";

app.beginPriv();

iProperty = identity[sProperty];

app.endPriv();

return iProperty;

});

The script in the .js accessing the fields in the form are not correct:

var vDate1 = event.target.xfa.resolveNode(topmostSubform[0].Page1[0].Date1[0]).rawValue.toString();

var vTime1 = event.target.xfa.resolveNode(topmostSubform[0].Page1[0].Time1[0]).rawValue.toString();

Firstly the main page in the form is not named, which makes referencing it difficult. If you call the page "page1", then remember that javascript is case sensitive.It should look something like this:

var vDate1 = event.target.xfa.resolveNode(form1[0].page1[0].Date1[0]).rawValue.toString();

var vTime1 = event.target.xfa.resolveNode(form1[0].page1[0].Time1[0]).rawValue.toString();

You will need to create a "Test" folder in the root directory "C:", as Acrobat will not create one for you.

Lastly it will not work in Reader unless the form is Reader Enabled.

================================

Reena

Jo_2005
Level 3
Level 3

Thank you for your reply.

I have removed the trusted function from script and referenced the field in a variable.

var myDoc = event.target;

var appname = event.target.xfa.resolveNode(topmostSubform[0].Page1[0].Applicants_Name[0]).rawValue.toString();

 

myDoc.saveAs("/c/forms/Template/Leave Application "

+ appname + ".pdf");

I now have a  an error for the field as follows:

topmostSubform[0] has no properties
3:XFA:topmostSubform[0]:Page1[0]:Applicants_Name[0]:exitException in line 3 of function top_level, script XFA:topmostSubform[0]:Page1[0]:Applicants_Name[0]:exit

topmostSubform[0] has no properties
3:XFA:topmostSubform[0]:Page1[0]:Applicants_Name[0]:exit

Also a security access error due to trusted function being removed:

NotAllowedError: Security settings prevent access to this property or method.
Doc.saveAs:3:XFA:topmostSubform[0]:Page1[0]:Applicants_Name[0]:exit

Can you please suggest amendments to the script?

Thank you very much for your assistance.

Jo_2005
Level 3
Level 3

Hello Reena,

I have modifed the script and it is now working.

I have placed the following script into the javascript folder:

var mySaveDoc = app.trustedFunction(function(doc) {

                                            
    app.beginPriv();
  
var myPath = app.getPath("user", "documents") + "/" + "Leave Application" + " " + empname + ".pdf";

    // saveAs is the only privileged code that needs to be enclosed
    // with beginPriv/endPriv
    doc.saveAs(myPath);
    app.endPriv();

});

The following script is placed in the exit event of the livecycle form field:

empname = xfa.resolveNode("xfa.form.topmostSubform[0].Page1[0].Applicants_Name[0]").rawValue

event.target.mySaveDoc(event.target);

Thank you for your help.

Geckoz100
Level 5
Level 5

Hello,

I realize it's been a while since this was posted.....I can't get this to work.

I know where to put the code for the exit event, no problem there.  Where exactly do you put the first portion of the script that you mentioned you put in the javascript folder?