These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

app.trustedFunction is supported in LCD, but does it actually work?

Spleckxa
Registered: Jan 6 2010
Posts: 32

Hello All,

I'm trying to use the addMenuItem method in the "docReady" event on my dynamic, LCD form. According to the LiveCycle Designer Scripting Basics manual, the addMenuItem is a support method.

However, upon further research, I've discovered that the addMenuItem method can only be used in a privileged context, which explains the "NotAllowedError: Security settings prevent access to this property or method." message I get when I try to use addMenuItem.

Fortunately, Acrobat apparently has another method called "trustedFunction" that allows a function to be executed in a non-privileged context.

However, even when I use the trustedFunction method on the "docReady" event of my LCD form, I still get the following error on the Javascript debugger:

"NotAllowedError: Security settings prevent access to this property or method. App.trustedFunction:3:XFA:form1[0]:CoverSheet[0]:Button1[0]:docReady"

Doesn't this kind of defeat the purpose of the trustedFunction method if the trustedFunction method must also be executed in a privileged context?

Here is my full test code I've placed in the docReady event:

var trustedMenuItem = app.trustedFunction(
function()
{
app.beginPriv(); // Explicitly raise the privilege
app.addMenuItem({cName:"Menu Test",
cParent: "Help",
cExec: "app.alert('Menu Item Test'); "});
app.endPriv(); // privileged and/or non-privileged code here
}
);
trustedMenuItem;

Is there anything else I can do, or is the trustedMenuItem method really not supported in LiveCycle Designer Forms for dynamic forms?

Thanks for any help!

David

My Product Information:
LiveCycle Designer, Windows
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
See Thom's excellent article on trusted functions: http://acrobatusers.com/tutorials/2008/10/using_trusted_functions
Spleckxa
Registered: Jan 6 2010
Posts: 32
Thanks, George,

I've already read Thom's excellent article on trusted functions, which is how I found out about it in the first place. I just thought that since LiveCycle Designer supposedly supports trustedFunction method, then trusted functions can be executed through a LiveCycle Designer form.

Thom's article suggests that the only place trusted functions can work is in folder level scripts or other privileged contexts. While this may be true, I'm still confused as to how LiveCycle Designer can support it?

What is a "privileged context" when dealing with LiveCycle Designer?

Thanks again for any help!

David
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
You would call a trusted function from code contained in the PDF. So you would have to load the file created by Designer in Acrobat or Reader (assuming Reader supports what your code wants to do) and trigger the code that calls the trusted function. And yes, the trusted function code should be in a folder-level JavaScript file, not somewhere in the document.