Previous Section | Next Section
...
Rule: Automatically Set Date to today's date
- Click the rules icon on the toolbar. Rules in the Guided Designer Navigation bar at the top of the page.
- Click Create a new rule and click the icon to edit it.
- Change the name of the rule to: Initialize form
Click on the Rule Builder button.
Click Next to go to the Action wizard.
The first action appears by default. If needed, click the Add Action button on the top right of the Action Wizard
Select TodaysDate from the first dropdown. TodaySDate is the Name of the Date control at the top of the form. If your control is named something else, select that control from the dropdown.replace TodaySDate below with that name
Select to from the second dropdown
Type today in the Expression field and click on the today function when it displays in the dropdown
Click Finish then click on thesave and test icon.
Save and Test. Now, when the end user first starts using the form, the Date control at the top will be set to today's date. No need for the user to type it in.
Expand title Click here to see this rule in the Visual Rule Builder
Rule: Set Price from Item
When the user selects an item in any of the rows in the Order Items table, we want the price of that item to be displayed automatically. Normally, this price information would come from a back end database or other system but we're just hard-coding the values in the rule for the time being.
- Click the icon Form in the toolbar Guided Designer Navigation barn to return to the form. In the Order Items table, select the Price column by clicking on the header. In the Properties panel, uncheck Enabled. The entire column is grayed out.
- Go back to the rules editor, create a new rule and edit it. Change the name of the rule to: Set Price for ItemChevrolet
- Run Builder. On the Condition wizard:
- Select the control 'Item'
- Select the operator 'Is'
- Click the toggle to switch to a Literal Value, and type Chevrolet.
- Click Next
- On the Action wizard, set the control Price to the literal value 125.75
- Click Finish. Your rule should look like this.
- Repeat Steps 2-5, creating two more rules.
- When Item is Chrysler, Set Price to 118.75
- When Item is Ford, Set Price to 132.75
Now, when the user selects an item, the price for that item will be displayed.
Info | |||||||
---|---|---|---|---|---|---|---|
frevvo rules also support JS custom code. Let's take a quick look at an example of the above Set Price rules in javascript. Click Rule Code then click Edit Code. In the Rule area, type or copy/paste the following.
|
...
Rule: Calculate Subtotals
...
Now, the overall Grand Total is automatically calculated and updated with the Subtotal amounts as rows are filled in and added to the table. Try deleting a row in the table. Notice the Subtotal amount for that row is subtracted from the Grand Total
has a powerful Rules engine. You can perform many dynamic actions in your form including the examples above as well as many other actions like connecting to back end systems and retrieving JSON to populate form controls. The Visual Rule Builder makes it easy to create rules to show/hide parts of the form, automatically fill in user information, make controls required or optional dynamically without writing code. For more information, refer to the Rules Examples documentation.