Expand my Community achievements bar.

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

Script is only working on the first occurrence of a masterpage

Avatar

Level 1

I have adopted a dynamic form on LiveCycle to maintain and update. I have no programming background, but have been working with LiveCycle every day for about the last three months figuring things out as I go.

I have a scripting problem that I do not know how to handle. I am using javascript. I currently have a script that will look at the <state> tag of an xdp. If the <state> value is a certain state, then a text in the “footer” subform of a master page becomes hidden while another text with a larger font becomes visible.

if (xfa.datasets.data.job.data.state.value == "NJ"){

     job.MasterPages.Liability_Continued.footer.liabilityFooterBig.presence = "visible";

     job.MasterPages.Liability_Continued.footer.liabilityFooter.presence = "invisible";

}

My problem is that the script is only working on the first occurrence of the master page. On all the others occurrences, it still shows the smaller text.

I have tried the script on the initialize, enter, exit, calculate, validate, validation state, presave, postsave, preprint, postprint, presubmit, postsubmit, docready, docclose, form ready, layout ready, and index change events of the “footer” subform, but all of these events have either not worked at all or only worked on the first occurrence of the subform.

How do I get the visibility of these text objects to change on all occurrences of the subform?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

There are two possible options. One is to loop through all of the instances of the Master Page and change the presence of the objects on each instance. The other would be to have the script in the layout:ready event of each of the objects referring to this.presence = "invisible";

So for example if your Master Page was called Page1, then this should work:

var oMaster = xfa.resolveNodes("Page1");

for (var i=0; i<oMaster.length; i++) {

     oMaster.item(i).job.MasterPages.Liability_Continued.footer.liabilityFooterBig.presence = "visible";

      oMaster.item(i).job.MasterPages.Liability_Continued.footer.liabilityFooter.presence = "invisible";

}

The exact reference in the script would depending on your hierarchy.

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

There are two possible options. One is to loop through all of the instances of the Master Page and change the presence of the objects on each instance. The other would be to have the script in the layout:ready event of each of the objects referring to this.presence = "invisible";

So for example if your Master Page was called Page1, then this should work:

var oMaster = xfa.resolveNodes("Page1");

for (var i=0; i<oMaster.length; i++) {

     oMaster.item(i).job.MasterPages.Liability_Continued.footer.liabilityFooterBig.presence = "visible";

      oMaster.item(i).job.MasterPages.Liability_Continued.footer.liabilityFooter.presence = "invisible";

}

The exact reference in the script would depending on your hierarchy.

Niall

Avatar

Level 1

Thank you so much.

I took this and wrapped it all in an if statement.

Since Liability_Continued was my master page, the script ended up looking similar to this:

if (xfa.datasets.data.job.data.state.value == "NY"){

var oMaster = xfa.resolveNodes("Liability_Continued");

for (var i=0; i<oMaster.length; i++)  {

     oMaster.item(i).footer.liabilityFooterBig.presence = "visible";

     oMaster.item(i).footer.liabilityFooter.presence = "invisible";

}

}