Expand my Community achievements bar.

Choice Subform Set Data Binding

Avatar

Level 2

We would like to use the choice subform set to display different subforms based on whether a hasScore value is set to YES or NO.  This will be done repeatedly in the form so we want to try and map all the choice subform sets that use the hasScore value to the same data instance in our XML.  When I attempt do this only the first choice subform set works.  The rest default to the first subform in the choice subform set.  The only way I get the rest of the choice subform sets to work is to duplicate the data instance in our XML to match the number of choice subform sets in the form.

Any way to get all the choice subform sets to use the same data instance in the XML?  Or is there a better way to do this without resorting to javascript to show/hide the subforms?  The choice subform set looks nice but we don't want to duplicate the XML data to get it to work.

What I have to do when I have 3 choice subform sets that use the hasScore value:

<?xml version="1.0" encoding="UTF-8"?>

<

loan_info>

  <score>

    <hasScore>YES</hasScore>

  </score>

  <score>

    <hasScore>YES</hasScore>

  </score>

  <score>

    <hasScore>YES</hasScore>

  </score>

  <scoreValue>742</scoreValue>

</

loan_info>

What I would like to when I have 3 choice subform sets that use the hasScore value:

<?xml version="1.0" encoding="UTF-8"?>

<

loan_info>

  <score>

    <hasScore>YES</hasScore>

  </score>

  <scoreValue>742</scoreValue>

</

loan_info>

6 Replies

Avatar

Former Community Member

The issue has to do with how the form and data combine to create the layout. This is done element by element so you cannot go back in the layout and you cannot go back in the data. Once you pass a reference point in the data (where you chose the 1st subform set) you cannot go back at some later point to check that same data item. Global binding is normally used for this (this sets up a variable in memory so that the value is always there). You coudl bind to a temp field and then write code to populate the real field with that same value. Then change the binding to global (on the real field) and all fields of the same name will be assigned that value.

Make sense?

Paul

Avatar

Level 2

Makes sense when talking about global b

inding for fields but there is no global binding for subforms.

So what's the best way to turn off/on subforms that rely on a data value that contains YES/NO?  Throughout our form we have pairs of subforms containing fields that we want to turn on/off depending on the data value that contains YES/NO.

Thanks,

Steve

Avatar

Former Community Member

You can either write some sophisticated logic in your form to handle it or try using a subform set and using an expression that evaluates the data value and indicates which subform to display (this might not work for interactive but definately will work for the initial rendering).

Paul

Avatar

Level 2

The subform set works but we have to repeat the data elements since we're using multiple subform sets in the form.  Gets back to your earlier reply on how we

can't go back in the data.

Too bad the expression in the subform set doesn't allow us to point to the same data element for all of the subform sets.  I like them because they show us where we're turning on/off subforms while that gets hidden when we put in JavaScript for this.

Thanks,

Steve

Avatar

Former Community Member

You shoudl be able to write an expression to point to the data element in the data dom.

xfa.datasets.data.rootnode.parentnode.childnode.value == "Yes"

as an example.

Avatar

Level 2

Paul,

I couldn't figure out how to reference the dataset value using the subform set.  Not real easy to figure out with the UI for the subform set.  Would prefer to just be able to put the JavaScript in the subform set selection code without having to do the dataset selection first.  Makes some pretty strange looking data bindings for the subforms that are part of the subform set.  Probably could use some more documentation on how to set these bindings up in the Designer help.

We ended up going with a top level ready:form script that could check the credit score Y/N value:

loan_info::ready:form - (JavaScript, both)

if (xfa.datasets.data.loan_info.form_extensions.forminator.hasCreditScore.value == "Y")

{

     loan_info.Page1.Score.presence = "visible";

     loan_info.Page1.NoScore.presence = "hidden";

     xfa.resolveNode("loan_info.Page1.#subform[3].Score[1]").presence = "visible";

     xfa.resolveNode("loan_info.Page1.#subform[3].NoScore[1]").presence = "hidden";

     xfa.resolveNode("loan_info.Page1.Score[2]").presence = "visible";

     xfa.resolveNode("loan_info.Page1.NoScore[2]").presence = "hidden";

}

else

{

     loan_info.Page1.Score.presence = "hidden";

     loan_info.Page1.NoScore.presence = "visible";

     xfa.resolveNode("loan_info.Page1.#subform[3].Score[1]").presence = "hidden";

     xfa.resolveNode("loan_info.Page1.#subform[3].NoScore[1]").presence = "visible";

     xfa.resolveNode("loan_info.Page1.Score[2]").presence = "hidden";

     xfa.resolveNode("loan_info.Page1.NoScore[2]").presence = "visible";

}

Too bad we couldn't use the subform set.  I liked seeing them in the hierarchy - makes ir pretty easy to see what's going on vs. JavaScript buried in the top level ready:form event.

We also had a case where we would have needed to turn on two of the three subforms in the subform set.  Might want to consider multiple selection for the subform set in future versions.

Thanks,

Steve