Field Rules

This documentation is based on the FoodCrunch use case. Please open the below link side by side to this page to understand the examples.
A Field Rule is a method of implementing automated actions on schema fields when a certain condition is met. It is made up of three components i.e. Action, Field and Condition.
  • Action: This component states what should be done when the condition(s) is/are met. It has the following options:
    • Disable
    • Hide
    • Require
  • Field: This is where the schema field is selected on which the action should be taken
  • Condition: Written in Javascript, the action is triggered when this is met.
For our FoodCrunch use case let's consider the following example to understand Field Rules. For all startups that are not in Pre-Seed stage, the funding value has to be mentioned. It is a required field.
For our use case the rule is that anytime the value of the Stage field is anything other than Pre-Seed, then the Funding is a required field otherwise it's optional.
Let's see how to implement this:
  • Ensure that Stage field is set to Required in field settings. This is required to ensure that a value is always selected.
Setting validation for a field
  • To create a Field Rule go to the schema (1) (i.e. in our case startups), select More (2) tab, click + (3) next under Field Rules and enter the selections for Action, Field and Condition (4). Click Save (5) when done. In our example the following values have been set
    1. 1.
      Action = Require
    2. 2.
      Field = funding
    3. 3.
      Condition in Javascript = data.stage.iv != 'Pre-Seed'
Creating a Field Rule
  • This can now be validated by trying to add content. Go to Content and try adding content. Immediately you will find that the stage and funding fields have a red flag.
    Fields with rules
    • If you set stage as Pre-Seed, the red flag denoting that the funding value is required is gone which means its optional.
    Rule validation example 1
    • If you set stage as any other value, the red flag remains meaning that a value has to entered in funding.
    Rule validation example 2
Last modified 3mo ago