Expand my Community achievements bar.

Script issue to drive subform visibility from dropdown

Avatar

Level 2

Hi, I have a drop down list that is driving the hidden/visible status of several subforms. This is a one to one, meaning if the user selects one dropdown choice, one subform appears. If they reselect, a different subform appears and the previous is hidden.

Using the script below, it works great for one subform but when I try to add additional statements to the script, it does not control the additional subforms. I think my issue is with the else if syntax necessary to add additional subform hide/visible statements which correspond to the other drop down selections (fyi, there are 14 options in my dropwdown menu and I have been testing with subforms for raw values 11 & 3):

if (this.selectedIndex == 11)

{

ActiveDirectorySubform.presence = "visible";

this.resolveNode("_ActiveDirectorySubform").setInstances(1);

}

else

{

ActiveDirectorySubform.presence

= "hidden";

this.resolveNode("_ActiveDirectorySubform ").setInstances(0);

}

if (this.selectedIndex == 3){

AssociatemachineSubform.presence = "visible";

this.resolveNode("_AssociatemachineSubform").setInstances(1);

}

else

{

AssociatemachineSubform.presence = "hidden";

this.resolveNode("_AssociatemachineSubform ").setInstances(0);

}

this.rawValue;

Can someone please help me get this right?

Thanks!!!!

10 Replies

Avatar

Former Community Member

Are you sure you want the setInstances command....what are you trying to accomplish by using that command?

Also what is the error message you are getting (I assume you are loking at the javaconsole for errors in your script).

Paul

Avatar

Level 2

I used the setinstance after failing with some other commands, but there is no real need for keeping as setinstance if there is a more efficiant way.

Following are the error messages:

GeneralError: Operation failed.
XFAObject.setInstances:7:XFA:LegaleDiscoveryForm[0]:PageSubform[0]:Navigationsubform[0]:GenInfoTypeSubform[0]:RequestTypeDrop[0]:exit
The element [min] has violated its allowable number of occurrences.

GeneralError: Operation failed.
XFAObject.setInstances:15:XFA:LegaleDiscoveryForm[0]:PageSubform[0]:Navigationsubform[0]:GenInfoTypeSubform[0]:RequestTypeDrop[0]:exit
The element [min] has violated its allowable number of occurrences.

Note: The "Repeat Subform for Each Data Item" on the Binding tab of each subform is not checked.

Thanks for your help Paul,

Todd

Avatar

Former Community Member

Are you sikply trying to add instances of that subform? If so the command woudl be addIntsance ...not setIntances()

Also the error is indicating that the subform is not set to allow more than one instance. Highlight the subform in the nierarchy view on on the object palette click on the Binding tab. The last entry has a checkbox to allow multiple occurances. Make sure taht checkbox is on.

Paul

Avatar

Level 2

THanks Paul, I'm getting closer. The subform associated with the first portion of the script (activedirectorysubform), appears and hides as intended. When I try the other selection (rawvalue 3 to drive visibility of Associatemachinesubform), the first subform hides but the intended subform does not appear. Follwign is the message from the script console:

this.resolveNode("_ActiveDirectorySubform").addInstances is not a function

7:XFA:LegaleDiscoveryForm[0]:PageSubform[0]:Navigationsubform[0]:GenInfoTypeSubform[0]:RequestTypeDrop[0]:exit

this.resolveNode("_ActiveDirectorySubform").addInstances is not a function
3:XFA:LegaleDiscoveryForm[0]:PageSubform[0]:Navigationsubform[0]:GenInfoTypeSubform[0]:RequestTypeDrop[0]:exit

Here is the modified script:

if(this.selectedIndex == 11){
ActiveDirectorySubform.presence = "visible";
this.resolveNode("_ActiveDirectorySubform").addInstances(1);
}
else{
ActiveDirectorySubform.presence = "hidden";
this.resolveNode("_ActiveDirectorySubform").addInstances(0);
}
if(this.selectedIndex == 3){
AssociatemachineSubform.presence = "visible";
this.resolveNode("_AssociatemachineSubform").addInstances(1);
}
else{
AssociatemachineSubform.presence = "hidden";
this.resolveNode("_AssociatemachineSubform").addInstances(0);
}

this.rawValue;

Any thoughts on what else I need to change?

The help is very much appreciated!

-Todd

Avatar

Level 2

Oops, novice error! That solved any errors appearing in the in the script console, but the "AssociatemachineSubform" still will not appear when the corresponding value is selected from the drowdown. Is there anyting else I could be missing here?

Avatar

Former Community Member

It would be easier if I coudl see the form.

Paul

Avatar

Former Community Member

It seems to be working fine for me .....when I choose option 3 I get subforms about machine names and data warehousing. When I choose option 11 I get info about partner names and active Directory targets. Am I missing something?

Paul

Avatar

Level 2

Thanks for validating this Paul, based on your feedback, I was able to figure out that I was assuming the rawvalue for the dorpdown selection I was testing was incorrect. It should have been 2, not 3. I was using the values from the drowdown binding field. Works perfectly! Thaks again for the help and patience!

-Todd