Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

What Form event occurs after a button click for importdata()

Avatar

Level 2

I have a dynamic form initially designed in LiveCycle then updated in AEM manager.  It has a section of dynamically added rows, and a user selected Dropdown for how many signature lines to include at the bottom of the table.  The signatures are hidden subforms and it works when the user changes the number on the dropdown.

However when I import data no code following the importdata seems to execute.  is there an easy way to read a value populated from the import and run a script to change the subform visibility without adding a second command button?

AFFM2519.#pageSet[0].Page1.sfrmBtnPgTop.btnXMLImport::click - (JavaScript, client)

xfa.host.importData();
xfa.form.recalculate(true);

I have tried adding a form level event in ready:form

AFFM2519::ready:form - (JavaScript, client)

Signers.fShowSign()

Made a Signers module with the below function.

function fShowSign()

{

var oldValue = AFFM2519.chkLstData.cboSigner.boundItem(xfa.event.prevText); 

var newValue = AFFM2519.chkLstData.cboSigner.boundItem(xfa.event.newText); 

  // For DEBUGGING purposes

// xfa.host.messageBox(oldValue + " --> " +newValue ,"Signers Selected", 2, 2);

// show the appropriate subform

switch (newValue) {

  case "0":

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign1").presence= "hidden";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign2").presence= "hidden";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign3").presence= "hidden";

  break;

  case "3":

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign1").presence= "visible";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign2").presence= "visible";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign3").presence= "visible";

  break;

  case "2":

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign1").presence= "visible";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign2").presence= "visible";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign3").presence= "hidden";

  break;

  case "1":

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign1").presence= "visible";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign2").presence= "hidden";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign3").presence= "hidden";

  break;      

  default:

  // hide all

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign1").presence= "hidden";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign2").presence= "hidden";

   xfa.resolveNode("AFFM2519.chkLstData.sfrmSign3").presence= "hidden";

  break;

}

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can find out which events fire after your script.

Just enter a script to every available event of the forms root node (i.e. form1) that prints its name into the Javascript console:

console.println("Executed event: " + xfa.event.name);

View solution in original post

4 Replies

Avatar

Level 10

When using the importData() method, the template and imported data will automatically be remerged into a new form. In scriptings all parts to happen after that remerge process won't execute. You'll have to split you scripings in several parts and assing those to suitable events.

For more details about the events read the scripting basics reference: https://helpx.adobe.com/pdf/aem-forms/6-2/scripting-basics.pdf

Alternatively, you can use another method to import data from XML files which doesn't require a remerge. Here a sample: LiveCycle Blog: XML per Skript in Adobe Reader importieren//Import XML via Script into Adobe Reader

Avatar

Level 2

I am unable to access the second link behind the company firewall.  I understand code following importdata() and remerge() functions execution in that code section doesn't execute.  What I am trying to find out is if after a on click button event and the form has remerged is there a form level event which could be used to take actions based on updated and remerged field values without having to add a manual mouse click button to call the code from.

Avatar

Correct answer by
Level 10

You can find out which events fire after your script.

Just enter a script to every available event of the forms root node (i.e. form1) that prints its name into the Javascript console:

console.println("Executed event: " + xfa.event.name);

Avatar

Level 2

There are a lot of places for event when attempting to determine which events occur in which sequence!  Based on radzmar's key information it took me days of placing events and testing to figure out the correct form event to use.  The answer is after the field event code runs with the ImportData(), place code on the top level of the form in the ::ready:form event to take any actions necessary following the import and before the user gets to interact with the form.  I marked this an answered and gave radzmar answer credit for the nugget that allowed me to map through the events.