Rules is a feature in Appstudio which allows styles to be applied to elements of an App depending on data, formatting it conditionally. This can be very useful in many scenarios like making it clear when something is wrong in a record or hiding something that is no longer relevant in a record. Examples of actions are:
- Hide a field when a Status field has a value of "Closed" (Hidden)
- Turn a field read-only if a question has been answered (Readonly)
- Make the Font of a number field red and bold if a value in the field is negative (Style)
We will be extending the use of Rules and what they can apply to overtime. If you have any requests please let us know in the comments sections of the article.
When setting a rule, you specify within an App which records it applies to using a filter, this filter will be the condition that needs to be met for the action of the rule to be applied to the Target fields. For more on how to create these filters please click here.
Note: The filter string does not require the '$filter=' at the start like form rules and workflow does
The edit page above has the following properties and options:
- Description - Name and purpose of the Rule, this can be extremely useful for other app builders to understand the purpose of the rule and to make sure they don't delete it by accident
- Filter - Specify a filter to state which records this rule applies to
- Target Fields - specify the fields to which the actions apply
- Actions - Options of actions to apply when the filter is met:
- Hidden - sets the fields to be hidden
- Read Only - sets the fields to be read-only, even when they are not read-only fields
- Style - Apply a specified style as defined in the Styles area
Remember to resync your app after changing Rules in order for them to apply, and remember Styles are only synced after a full log out and log back in