On Delete: Difference between revisions
Marek Rodak (talk | contribs) |
Marek Rodak (talk | contribs) |
||
| Line 17: | Line 17: | ||
==Example: Repeatable group counter== | ==Example: Repeatable group counter== | ||
Each instance of the repeatable group in the questionnaire is counted | Each instance of the repeatable group in the questionnaire is counted. | ||
Create a shared variable (integer) repeatableCounter. If the questionnaire is new, assign 1 to the repeatableCounter. | Create a shared variable (integer) repeatableCounter. If the questionnaire is new, assign 1 to the repeatableCounter. | ||
| Line 34: | Line 34: | ||
Create a new question group (Conclusion) and add a Whole Number component (Inspected components). This is where we assign the result of the counter. | Create a new question group (Conclusion) and add a Whole Number component (Inspected components). This is where we assign the result of the counter. | ||
{{Note|Conclusion group can be set as non-visible and display the result only at report.}} | |||
[[File:OnDeleteExampleconclusiongroup.PNG|600px]] | [[File:OnDeleteExampleconclusiongroup.PNG|600px]] | ||
Set up a following On Save rule. If repeatableCounter contains data, assign its value to the question | Set up a following On Save rule. If repeatableCounter contains data, assign its value to the question Inspected components. | ||
[[File:OnSaveConclusion.PNG|600px]] | [[File:OnSaveConclusion.PNG|600px]] | ||
Revision as of 08:30, 1 December 2022
| Rules and examples |
|---|
|
| Warning | Work in progress! We are in the process of updating the information on this page. Subject to change. |
Rules are client-side scripts (no-code business logic) that are executed when a user of the mobile app interacts with the app. The On Delete rules are executed when an existing instance of a repeatable group is deleted. Rules are managed using the rules editor.
On Delete rules are available for the following components: Questionnaires
Repeatable group
On Delete rules are only applicable to Repeatable groups. Questions are usually organized into groups. Instead of creating a questionnaire with the same set of questions multiple times, repeatable question groups offer the ability to repeat the grouped questions either arbitrarily (not known beforehand) or precisely specified number of times. Group can be set as repeatable in questionnaire properties.
Repeatable question groups are useful in cases such as:
- User needs to enter multiple addresses
- User needs to enter data about more than one result of the same issue (checking 10 identical parts of a machine)
- User needs to enter multiple pictures of the same object
Example: Repeatable group counter
Each instance of the repeatable group in the questionnaire is counted.
Create a shared variable (integer) repeatableCounter. If the questionnaire is new, assign 1 to the repeatableCounter.
| Note | The default value in the variable is 0. When the questionnaire is loaded, one instance of the repeatable group already exists. Therefore, we have to set the value to 1. This has to be set in the root question On Load. If we set the On Load rule for a repeatable group, the value will be set to 1 each time a new instance is created. |
For the repeatable group, set the following On Repeat rule: If a new instance of a repeatable group is created, repeatableCounter +1.
For the repeatable group, set the following On Delete rule: If an instance of a repeatable group is deleted, repeatableCounter -1.
Create a new question group (Conclusion) and add a Whole Number component (Inspected components). This is where we assign the result of the counter.
| Note | Conclusion group can be set as non-visible and display the result only at report. |
Set up a following On Save rule. If repeatableCounter contains data, assign its value to the question Inspected components.