1

On Repeat

From Resco's Wiki
Jump to navigation Jump to search
Rules and examples

File:On repeat.pngalt=On Repeat icon 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 Repeat rules are executed when a new instance of a repeatable group is displayed. Rules are managed using the rules editor.

On Repeat rules are available for the following components: Questionnaires

Repeatable group

On Repeat 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.

repeateable group enabled in question group porperties

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: Add numerical suffix to the label of each repeatable group instance

In this example, we want each instance of a repeatable group additionally labeled by number. Our repeatable group is focused on multiple accounts.

Create a repeatable group with a lookup component and set up a target on the Account.

On Repeat: Add numerical suffix to the label of each repeatable group instance rule example part 1 (create repeatable group)

In the On Load rule, we want to set up the following: If the questionnaire is new, we want to add the suffix (1) to the repeatable group label. This adds number 1 to the end of our repeatable group label.

On Repeat: Add numerical suffix to the label of each repeatable group instance rule example part 2 (set up the On Load rule which adds suffix)

In the On Repeat rule, we add a step that will concat string Account and IndexRepeat.

On Repeat: Add numerical suffix to the label of each repeatable group instance rule example part 3 (set up the On Repeat rule)

To see the rule execution in the app, click here.

Example: Add value from lookup target to the label of repeatable group

Let's say: "We are on an inspection, where the equipment has multiple components". Repeatable groups are ideal for this kind of inspection. The following example is divided into two parts.

In the first part of the exercise, we create a child custom entity Asset Component, which will be linked to the parent Asset we are currently inspecting. In the second part of the example, we set up all the necessary rules to set the label of the repeatable group to the specific component.

First part:

In the Admin Console, we create a custom entity called Asset Component.

On Repeat: Add value from lookup target to the label of repeatable group part 1 (create a custom entity)

We create a lookup field called Parent Asset with Asset as a target.

On Repeat: Add value from lookup target to the label of repeatable group part 2 (create a lookup field)

Second part:

This is what our questionnaire looks like. We have two groups: Asset and Component. Asset group is where we have Asset lookup. This is where we choose the equipment, we are currently working on. Component group is a repeatable group where we add our components.

Note It is possible to load the Asset from an entity where we initiate the inspection automatically. For simplicity, we choose not to. Here is an example how you can load Asset (or any entity) automatically: Populate the questions with data from regarding lookup entity 2

On Repeat: Add value from lookup target to the label of repeatable group part 3 (questionnaire groups)

Let's set the On Repeat rule for the repeatable group (Component). If the group isLoaded and Changeditem is component, create a variable where we concat string "Component: " and the component question value. We then assign this variable to the group label.

On Repeat: Add value from lookup target to the label of repeatable group part 4 (On Repeat rule)

Additionally, we set up a lookup filter to filter out all the components which are not part of the asset we are currently working on. In order to do that we have to set up an On Change rule for Asset group. Create a shared variable where we assign current Asset.

On Repeat: Add value from lookup target to the label of repeatable group part 5 (On Change rule which serves as a filter)

In the Component group, add a filter for component question lookup and set the following:

On Repeat: Add value from lookup target to the label of repeatable group part 6 (additional filter)

This is the result:

On Repeat: Add value from lookup target to the label of repeatable group part 7 (result)




Was this information helpful? How can we improve?