On Delete: Difference between revisions
Marek Rodak (talk | contribs) Created page with "{{Rules TOC}} {{WIP}} <span style="float:left; padding-right:10px">100 px</span> Rules are client-side scripts (no-code business logic) that are exe..." |
Marek Rodak (talk | contribs) No edit summary |
||
| (10 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{Rules TOC | {{Rules TOC}} | ||
<span style="float:left; padding-right:10px">[[File:On repeat.png|100 px]]</span> | <span style="float:left; padding-right:10px">[[File:On repeat.png|alt= OnDelete icon|100 px]]</span> | ||
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]]. | 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]]. | ||
| Line 8: | Line 8: | ||
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. | 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. | ||
[[File:Properties repeatable groups.PNG|250px]] | [[File:Properties repeatable groups.PNG|alt=Setting questionnaire group as repeatable|250px]] | ||
Repeatable question groups are useful in cases such as: | Repeatable question groups are useful in cases such as: | ||
| Line 15: | Line 15: | ||
*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 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 | *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.}} | |||
[[File:OnLoadCounter.PNG|alt=On Delete: Repeatable group counter exmple part 1 (On Load rule)|600px]] | |||
For the repeatable group, set the following On Repeat rule: If a new instance of a repeatable group is created, repeatableCounter +1. | |||
[[File:OnRepeatcounter.PNG|alt=On Delete: Repeatable group counter exmple part 2 (On Repeat rule)|600px]] | |||
For the repeatable group, set the following On Delete rule: If an instance of a repeatable group is deleted, repeatableCounter -1. | |||
[[File:OnDeletecounter.PNG|alt=On Delete: Repeatable group counter exmple part 3 (On Delete rule)|600px]] | |||
Create a new question group (Conclusion) and add a Whole Number component (Inspected components). This is where we assign the result of the counter. We set the question group as non-visible to display the result only in the report. | |||
[[File:OnDeleteExampleconclusiongroup.PNG|alt=On Delete: Repeatable group counter exmple part 4 (counting of the groups)|600px]] | |||
Set up a following On Save rule. If repeatableCounter contains data, assign its value to the question Inspected components. | |||
[[File:OnSaveConclusion.PNG|alt=On Delete: Repeatable group counter exmple part 4 (On Save rule)|600px]] | |||
Report: | |||
[[File:InspectedComponents.PNG|alt=On Delete: Repeatable group counter exmple part 5 (showcase)|600px]] | |||
{{Feedback}} | |||
Latest revision as of 12:34, 20 November 2023
| Rules and examples |
|---|
|
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. We set the question group as non-visible to display the result only in the report.
Set up a following On Save rule. If repeatableCounter contains data, assign its value to the question Inspected components.
Report:
{{#CI form: title = Was this information helpful? How can we improve?
| type = inputs
| [textarea]
}}