简体   繁体   中英

Livecycle (JavaScript) code not running in order

Good Afternoon,

I am in the process of making a PDF form in Livecycle ES2 using JavaScript.

I have created a button (Lockbutton1) on my form in the "click" event which uses the below code, to make all fields on several subforms “read only” and then prompt the user with a “Save As” box.

FORM.Page1.LockButton1::click - (JavaScript, client)

// Lock all fields in subforms except for signature subforms

oTargetField = this.resolveNode("SubformTop");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEP");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLN");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLNR");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEPR");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEPRD");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEPRI");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLNRD");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLNRI");
    oTargetField.access = "readOnly";

// Hide other buttons and text

this.resolveNode("ResetButton1").presence = "invisible";
this.resolveNode("PrintButton1").presence = "invisible";
this.resolveNode("FormType").presence = "invisible";
this.resolveNode("$").presence = "invisible";
this.resolveNode("Splashtxt").presence = "invisible";

// Save the form
app.execMenuItem("SaveAs");

However, when the user clicks on the lock button, the user is first prompted with the “Save As” box and once the form is saved, then the rest of the code kicks off, making the subforms read only and hiding the buttons and text.

I dont understand why the first thing to kick off is the "Save As" box, when this should be the last thing to kick off from within the code.

I need the process to work in the below order:

  1. User clicks Lock button.
  2. Specified subforms are changed to read only.
  3. Buttons and text go invisible.
  4. User is prompted with “Save As” box.

Anyone have any ideas what's happening and how I can fix?

Regards,

A

Your code logic is OK. Check if all nodes have the same names as defined in LiveCycle. See below a sample and the result:

代码样例

PDF结果

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM