BizForm Drop-down Lists Populated by Page’s Children

Jacob Reyes asked on May 30, 2018 18:34

Greetings,

I've built an online form with two important fields that dictate which regional office’s department will get the notification form. Here’s the deal – I’m using a macro expression to lists the DisplayNames of the regional offices’ to populate the 1st dropdown.

The second drop-down then uses that value to get the list of departments for that regional office. That is where I’m having trouble - using that value to get the list of DisplayNames for the second dropdown.

Here's how I imagine the two fields to work:

  • Drop-down 1 lists the Regional offices – North; East; West; and South. The user selects region - West.
  • Drop-down 2, which is disabled until drop-down 1 has a value, uses the selected value (West) in a macro expression to lists regional office’s department numbers (510, 511, etc.).

The end result: drop-down 2’s value is used in the notification recipient email field - {%DeptNum%}@company.com.

Here’s an example of the document tree: Regional Offices (Parent to Regional offices')

  1. East (Parent to dept) > 510 (dept#), 511, 512, etc.
  2. West > 610, 611, 612, etc.

Here's the macro expression I’m using to get the DisplayNames for drop-down 1:

Documents["/Company/Regional-Offices"].Children.DisplayNames;#

For drop-down 2, I’ve tried using a conditional statement to return the value, for example:

regOff = Region.Value; if(regOff != “”){Documents["/Company/Regional-Offices"].Children.West.AllChildren.DisplayNames; }#

I even tried something on the lines of -

Documents["/Company/Regional-Offices"].Children.{% Region.Value%}.AllChildren.DisplayNames; 

I thought about trying my luck with a foreach statement, but I’m a little confused by the macro expression example in the documentation. Any suggestions would be much appreciated.

Correct Answer

Dragoljub Ilic answered on May 31, 2018 11:29

Hi Jacob,

If I understand you well, all of your data that you need in dropdown is placed under pages tree? If yes, you can do something like this:

For first dropdown:

  1. Make it required and check 'Has depending fields'
  2. Under 'Editing control settings' click on 'Advanced' and check 'Display actual value as item'
  3. As DataSource check 'Macro expression' and add this macro: Documents["/Company/Regional-Offices"].Children
  4. In 'Item transformation' field put {% DisplayName %}
  5. For 'Value column' use {% NodeAliasPath %}

For second dropdown:

  1. Make it required and check 'Depends on another field'
  2. As 'Enabled condition field' add something like this !String.IsNullOrEmpty(Dropdown1FieldName.Value)
  3. As DataSource check 'Macro expression' and add this macro: Documents[Dropdown1FieldName.Value].Children.WithAllData
  4. In 'Item transformation' field put {% DisplayName %}
  5. For 'Value column' use {% NameOfTheField %} - Name of the field that you want to save in form, maybe region ID, or region name.

Hope this will help.

Best regards, Dragoljub

2 votesVote for this answer Unmark Correct answer

Recent Answers


Jacob Reyes answered on May 30, 2018 23:20

Re-read the documentation on Iteration loops. Got a little further along, but still can't figure out how to concatenate the drop-down 1 value with the foreach.

pages = Documents["/Company/Regional-Offices"].Children; 
deptNum = Region.Value; 
if(pages.Count > 0){
foreach(d in pages){
d.DisplayNames
}
};#
0 votesVote for this answer Mark as a Correct answer

Jacob Reyes answered on May 31, 2018 23:05

Hi Dragoljub,

That did the job! Thank you so much for the help.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.