Advanced form scripting
This page supplies additional technical documentation, especially in regards to form elements and files.
Form properties
The following properties are accessible within all places in the form.
Property | Description |
Q42 | Returns an Object containing details related to the question with ID Q42. If there are multiple occurrences of Q42 the closest match will be returned. Assume that Q42 resides in a duplicatable question group. If referenced from a question within the same group then this will return the Q42 instance in the same question group as the referenced question. Otherwise search would continue up the group hierarchy from where it was referenced to find Q42. |
QG1 | Returns a list of Objects containing details related to the question group with ID QG1. If there are multiple occurrences of QG1 the closest match will be returned (similar to how question instances are found). Some useful deductions QG1.Q42.answer - points to a list of answers for Q42 inside all QG1 instances. |
formAnswer.questionAnswers | Returns a Map of question answers directly under the form model. The key is the question ID and the value is an Object representing question answer details. A useful deduction formAnswer.questionAnswers.Q42 - points to Q42 at root level |
formAnswer.questionGroupAnswers | Returns a Map of question group answers directly under the form model. The key is the question group ID and the value is a list of Objects representing question group answer details. |
form | This will return an Object representing details of a particular form version. |
formAnswer.Q42.answer | Gets answer to first occurrence of Q42. Note that the difference to just using Q42 is that if e.g. Q42 resides inside question group QG1, and QG1 is a root question group, then with form.Q42 you will always get same as formAnswer.QG[0].Q42. If you however use Q42 only and you reference it from a question, or another item within QG[2], then you will get form.QG[2].Q42. |
questionAnswers | Returns a Map of question answers directly under the closest question group. The key is the question ID and the value is an Object representing question answer details. If no question group exists this is the same as invoking formAnswer.questionAnswers. |
questionGroupAnswers | Returns a Map of question group answers directly under the closest question group. The key is the question group ID and the value is a list of Objects representing question group answer details. If no question group exists this is the same as invoking formAnswer.questionGroupAnswers |
Removing and adding question group instances
markAsRemoved() and addGroupInstance() operations are available on an Object representing the question group answer.
Statement | Description |
QG1[0].markAsRemoved() | Marks the first instance of QG1 as to be removed. markAsRemoved() method available for any question group. |
QG1[0].addGroupInstance('QG2') | Adds an instance of QG2 into QG1[0]. The addGroupInstance() method is available for any question group. An added question group answer Object is returned. |
addGroupInstance('QG1') | Adds an instance of QG1. i.e: QG1 is a question group directly under the form model (it is not inside another question group). An added question group answer Object is returned. |