Functions and Events Used in the ROS Application
Last updated 19/01/2022
How to Add a Function and Attach it to an Event
The following video shows how to write a function in Five and attach it to an event.Steps
1. Select Functions in the menu.2. Click the Add Item button in the list app bar.
3. Type an ID in the Function ID field.
4. Click the lookup in the Language field and select a language.
5. Click in the Code field to open Five's Code Editor.
Figure 1 - Add a function
6. Type your code in the editor.
7. Click the Save button in the editor.
Figure 2 - Add the code
8. Click the Save button in the form app bar.
Figure 3 - Save the function
9. Select the menu item you need to attach the function to.
10. Select the record in the list.
11. Click the Events tab.
Figure 4 - Events tab
12. Click the lookup icon in an event field and select the function ID.
13. Click the Save button in the form app bar.
Figure 5 - Attach the function and save the record
AssignRole()
Form | Event | Executes | Function Example |
---|---|---|---|
Applications | Do Logon | Server | AssignRole() |
To execute the validation set on the Show If and Read Only If fields on the Orders form:
(form.variable.Role === 'Dispatch')
DispatchCompleteOrder()
Form | Event | Executes | Function Example |
---|---|---|---|
Form | Do Complete | Server | DispatchCompleteOrder() |
The DispatchCompleteOrder() will execute when the Save button is clicked for the Orders form. The DispatchCompleteOrder() will be called and calculates the full name of the dispatch user to store in a notification to the client (Restaurant) informing their order has been completed.
If an error occurs on the Orders form, this includes the Items sub-form, the data will not be saved to the database.
ValidDiscountCode()
Form | Event | Executes | Function Example |
---|---|---|---|
Forms | On Validate | Client | ValidDiscountCode() |
The ValidDiscountCode() will execute and show a message if a discount code entered on the Item's form Discount Code field does not match one of the codes in the array of the ValidDiscountCode function.