Previous Section | Next Section
...
- Click the Copy icon to make a copy of the Order Info form. Then, click the Edit icon to open the Form Designer.
- In the Properties Panel, change the form name to Order Info Rules.
Rule: Automatically Set Date to today's date - Build this rule with the Visual Rule Builder
- Click the rules icon on the toolbar. Create a new rule and click the icon to edit it.
- Change the name of the rule to: Initialize form
In the Rule area, type or copy/paste the followingClick on the Rule Builder button.
Click Next to go to the Action wizard.
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
Code Block language javascript linenumbers true if (form.load) { TodaySDate.value = frevvo.currentDate(); }
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 the save and test icon. Today's Date should be populated with the current date when the form loads. 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
...
- Click the icon in the toolbar to return to the form. In the Order Items table, select the Subtotal column by clicking on the header. In the Properties panel, uncheck Enabled. The entire column is greyed out.
- Go back to the rules editor, create a new rule and edit it. Change the name of the rule to: Calculate Totals
In the Rule area, type or copy/paste the following.
Code Block language javascript linenumbers true var grandtotal = 0.0; for (var i = 0; i < Item.value.length; i++) { if (Item[i].value.length > 0 && Quantity[i].value > 0) { var subtotal = Price[i].value * Quantity[i].value; Subtotal[i].value = subtotal; grandtotal += subtotal; } } GrandTotal.value = grandtotal; var x = OrderInformationRepeat.itemRemoved;
Now, when the user selects an item and a quantity, the subtotal for that line and the overall grand total are automatically calculated and updated. The last line triggers the rule whenever a row is deleted from the table.
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 showing/hiding parts of the form, automatically filling in user information, making controls required or optional dynamically, connecting to back end systems and retrieving JSON to populate form controls etc. Form more information, refer to the Rules Examples documentation.
...