In ClaySys AppForms you can use Rules to execute or perform various actions in the form. The term Global Rules is the new and advanced feature that is introduced in Claysys AppForms. Global rules will create rules for the tenants which can be accessed using Rules Engine for any form. All parameters in the global rules are passed as references. While calling a rule from Rules Designer, the control properties or the rule variables can be passed as parameters.
How to configure Global Rules in ClaySys AppForms.
In the left pane of the AppForms designer page window you can see the option for Global Rules in Data Management tab.
This is the window for creating Global Rules. There are two options, either we can create a new global rule or modify the existing one.
You can also delete the parameters as well. Click on the delete button to delete the created parameter from the rule.
If you need to use the parameter ‘age’ in the Global Rule, you need to write it as ‘age.Value’ in the rule as this value is being passed to the forms where you use the Global Rule. On selecting the Global Rule from expression builder, the parameters also will be automatically added to the expression.
And click ‘Done’ button to complete it. And the Global rule is created
If you need to delete any rule. Select the rule then click delete button to delete it.
To rename the rule that you have created there is one text-box on the top of ‘Manage Rule’ tab, and you can type the new name and click save button to rename it.
Now you can write the actions in the rule and click save rule button to update the rule with the changes. Here in this example we are writing a rule to check the age category.
And if you need to make any changes in the parameters that you have added you can change it here. For that click on the ‘Manage Parameters’ button and a pop-up will appear.
In the pop-up make the changes and click ‘save’ button.
Then the parameter will get updated and gets a notification pop-up.
Now go to the rule and update the name of the parameter as,
Now go to form explorer and open the form were you want to add this global rule. Place a button in the form and create a new rule in the trigger of the button.
To call the global rule you should add an action like this:
The syntax of global rule is shown below. The Function GlobalRule() has two arguments. The first argument is the name of the Global Rule itself, second argument is the name of the Control Name where the global rule parameter should map. So in this example the global rule parameter is ‘AgeVar’ and it should map to the Control (TextBox) in the form where we are giving the age value.
Load the form and then trigger the rule where the global rule is called and you can see that the global rule is triggered and it is working.
Download and Upload Global Rule
Then a pop-up will appear to get the confirmation from user to proceed.
And clicking OK button will delete the global rule from the tenant.
Consider you are making any changes to an existing global rule, and the form using it is open in any other tab.
If your modifications need to be available in the existing form, you need to close the browser and open the form again. This is because of the fact that the Global Rules are taken from the session.
So once you make any modifications to a global rule and these changes are required in an open form, the session need to be closed and re-opened.