Parent / Child Related Lists

Thanks to the dynamic piping features you may create cascading lists that are generated dynamically based on other lists selections.

In this example we will suppose that we already have a table of companies and employees and take a list of those companies and a list of their employees to show how to link both to create a dynamic parent / child related list.

1. The company SQL answer type

First things first we need to create a new SQL Answer type for the companies list that will get all companies from the database and their ids.

SELECT Id, Name FROM Company

Now that we have our company list we can add this newly created answer type to any questions or our survey. Once its added open its answer properties and set its pipe alias property to : CompanyId

2. The employee SQL answer type

We have now to create our employee answer sql answer item that will be linked to the companies. To do that create a new answer sql type with following query

SELECT Id, Name FROM Employee WHERE CompanyId = @CompanyId

Add a new SQL parameter to your SQL answer type with following parameters

  • name CompanyId, value: [[CompanyId]]

Next add that employee SQL list answer type to any of your survey question. ngSurvey will during the survey lookup the answer having a pipe alias set to CompanyId and use the value entered / chosen by the respondent as a parameter for the employee query. In our example it will retrieve all the employee of the selected company of the other sql list.

If you only want to show the list when there is an actual result you can enable the Hide on empty query results which will hide the list as long as the respondent did not select any value in the company list.

There are no limits on the number of lists that can be inter-connected and you can as well connect any other ngSurvey answer type that support value piping to your list

Last updated

(c) 2024 Data Illusion Zumbrunn. All rights reserved. Reproduction strictly forbidden.