Compound question

Collects answers that consist of multiple fields. Allows for repeating set of sub-questions.

For complex data sets, nest sub-questions within main questions to create hierarchical structures. By doing this, you can easily analyze data about specific medications, including dosages, or family health conditions that affect siblings and parents. Repeat this question multiple times (unlimited, fixed number, or based on another variable answer) so responders can enter information as many times as they need.

Unlike most answers, a compound answer value is stored as an object, since it contains multiple parts.

{
	"emergencyContact": {
		"name": "John",
		"lastName": "Doe",
		"email": "john@doe.com"
		"phone": "2345..."
	}
}

Using compound answers in templated strings

If you would like to access one of the parts of a compound in a string template, you can use the get template function.

e.g.

We'll call {{emergencyContact | get 'phone'}} in case of emergency. would render We'll call 2345... in case of emergency.

Using compound answers in conditional logic

In the conditional logic editor, you can select fields of a compound question to conditionally show a question, step or question. e.g. If you want to show a boolean question โ€œRenew insuranceโ€ when insurance is expired, you can set conditional logic as following.

Repeating question group answers

It is possible to submit multiple answers to a compound question. The repetition count can be set to three different options.

  • Unlimited: Responders can add as many answers as they want by clicking on +add in the flow itself.

  • Fixed number: Set a fixed number of answers for the responder to answer. e.g. 2 emergency contacts in an intake form.

  • Another answer/variable: Add a question prior to the compound question that will set the number of answers required in the compound question. e.g. First ask for the number of medicines or pass it via url, then use the compound question to ask for specific questions about the medicines as many times as set in the medication number question.

Repeating compound answers appear in form payload as array of objects. e.g.

{
	"numberOfMedicines": 2,
	"medicines": [
		{
			"name": "Medicine 1",
			"dailyDose": 2,
		},
		{
			"name": "Medicine 2",
			"dailyDose": 3,
		}
	]
}

Conditional fields

Fields (sub-questions) in a compound question can be shown based on other answers/variables just like regular questions. If you want to show a field based on other fields in the same compound question, you can set conditional logic in the logic editor. e.g. You have a compound question asking for work experience and you want to ask for โ€œend dateโ€ only if the responder quit the job.

Layout in compound questions

You can have multiple fields in a row in a compound question โ€” just like other questions in a step. You can drag/drop and reorder fields. We currently do not support moving fields in or out of a compound question.

Copy-pasting compound questions

You can copy and paste compound questions just like other questions, but currently, copying and pasting fields inside a compound question (sub-questions) is not supported.

Setting compound answers via URL parameter

If you'd like to pass a compound answer into the form instead of requiring the responder to answer a question, you can use object notation like in address answers. e.g.

https://your-flow-url.com?emergencyContact[name]=John+Doe&email=john@doe.com

Passing multiple compound answers via url is currently not supported. It will be addressed soon.

Last updated