Jump to content

On Create: Difference between revisions

From Resco's Wiki
Marek Rodak (talk | contribs)
Line 38: Line 38:
[[File:Reuse fetch modify.PNG|300px]]
[[File:Reuse fetch modify.PNG|300px]]


The most important are the last two conditions. Reuse fetches completed questionnaires where the custom field reuse_customer is equal to the shared.Customer and reuse_equipment is also equal to the shared.Asset.  
;Conditions:
*created by current user
*is not a template
*used template is equal to one we chose
*status equals completed
 
The last two conditions are avaliable only after creating custom fields. Reuse fetches questionnaires where the custom field reuse_customer is equal to the shared.Customer and reuse_equipment is also equal to the shared.Asset.  


[[File:Reuse fetch.PNG|600px]]
[[File:Reuse fetch.PNG|600px]]

Revision as of 10:13, 16 November 2022

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 Create rules are executed before a questionnaire or report instance is created. Rules are managed using the rules editor.
On Create rules are available for the following components:

Questionnaires

On Create rules in questionnaires can be used to define additional variables which can be used in the reuse fetch. This can ensure that inspectors can select from a relevant list of answered questionnaires.

Note Requires version 3 (or later) of rules and version 15.0 (or later) of the mobile app.
Rule execution
  • When a questionnaire instance is about to be created. This happens even before the On Load event.

Example: Reuse fetch extended by OnCreate rule

Warning Work in progress! We are in the process of updating the information on this page. Subject to change.

In this rule, we want to reuse answers from previous questionnaires. While using OnCreate, we can extend reuse fetch possibilities by adding additional conditions. Let's say, "we start the questionnaire from the workorder." We aim to reuse only those questionnaires done on the same customer and asset.

First, we must create custom fields on the questionnaire entity (via Admin Console). These custom fields will serve as an additional condition in reuse fetch. The first is reuse_customer with account lookup, and the second is reuse_equipment with asset lookup.

Right after, we have to enable these two fields in the Questionnaire entity, in the app project.

Now, we can start with the OnCreate rule (Questionnaire Designer). Two shared variables are necessary: shared.Customer type account and shared.Asset type asset. If the new questionnaire was created from the workorder, load reference from the workorder into the variable Workorder_ref. If Workorder_ref contains data, can we populate shared variables. We assign customerid into shared.Customer and assetid into shared.Asset.

Reuse fetch can be modified in the right pane of Questionnaire Designer.

Conditions
  • created by current user
  • is not a template
  • used template is equal to one we chose
  • status equals completed

The last two conditions are avaliable only after creating custom fields. Reuse fetches questionnaires where the custom field reuse_customer is equal to the shared.Customer and reuse_equipment is also equal to the shared.Asset.

Report Designer

Report Designer also supports rules that can add some business logic to your reports. In the case of the Report Designer, whenever a new report is created, or a new instance of a repeating block is created, an On Create event is triggered.

Note For reports, the steps don't allow you to control the user interface (enable or disable a field, show or hide something, etc.); you can only assign values to variables or perform arithmetic operations.

To define the steps, proceed as follows:

  1. Select either the report body or a repeater.
  2. Click Edit Sources to display a list of variables defined for that component.
  3. Select any variable and click On Create to display the rules editor.
  4. Use the usual Rules editor syntax to define one or more steps that should be performed.
  5. Remember to save all changes.
Rule execution
  • When a new report is created.
  • When an instance of a repeating block is created.

Examples

Report Designer examples include several ideas on how the On Create rule can be used in reports.

Schedule Board

You can configure business logic in the toolbar. Schedule Board supports two types of rules, On Create is one of them. The On Create rule triggers when a new activity (task) entity is created based on the source entity.

Rule execution
  • When the source entity item is dragged from the list of source entities onto the timetable.