Skip to main content
sdbrigma
Participant
April 25, 2017
Question

General Error When Using execDialog

  • April 25, 2017
  • 2 replies
  • 505 views

I'm trying to create a dialog box form a mouse up action in a form, but the text that's entered in the box never appears in the assigned field.

Here is the code that I have in a separate file within C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Javascripts

function trustedDialog(data){

  console.println("trustedDialog function");

  app.beginPriv();

  try {app.execDialog(data);}

  catch (e) {console.println("Trusted Dialog box exception is: " + e);}

  app.endPriv();

  return;

  };

  app.trustedFunction(trustedDialog);

Here is the code that I have for the mouse up event.

var oDlg = {

  strName: "", initialize: function(dialog) {

     dialog.load({"usnm":this.strName}); },

        commit: function(dialog) {

              var data = dialog.store();

              this.strName = data[ "usnm"];},

        description: { name: "KSA Input Box", elements: [

        { type: "view", elements: [

        { name: "Enter your text here:", type: "static_text", },

  { item_id: "usnm", type: "edit_text", char_width: 15, multiline: 1, height: 500, width: 500},

  { type: "ok_cancel", },

  ] },

  ] }

};

var f = this.getField("TextBody");

if( "ok" == trustedDialog(oDlg)) {

    f.value = oDlg.strName;

}

Whenever I run my code I'm getting this error in the console, and I haven't been able to figure out why.

Exception in line 35 of function trustedDialog, script Folder-Level:App:priveleges.js

Trusted Dialog box exception is: GeneralError: Operation failed.

This topic has been closed for replies.

2 replies

Inspiring
April 25, 2017

You're also going to have to use the app.trustedFunction method in your folder-level JavaScript, e.g.,

var trustedDialog = app.trustedFunction(function(data) {

     // code goes here

});

If you're doing this so you can specify a window title and get rid of the warnings, see the sample code included with the documentation of the app.trustPropagatorFunction in the documentation.

try67
Community Expert
Community Expert
April 25, 2017

I'm not sure that's the issue but you are not returning the value of the execDialog method in your trusted function, so this line is not going to work:

if( "ok" == trustedDialog(oDlg)) {