With the introduction of being able to give rules names it has created something new and wonderful, well for me it has and even now when i am sitting in Pret having breakfast and writing this article I am still thinking how great it is. So what is this wonderful thing I am talking about you may be asking.
Well it’s the ability to have a rule on a view that is not related to any event like a button click or when a drop down list is changed. So these rules are basically not bound to any event on the view they have become Unbound.
First lets take a look at how easy it is
Building a view with these unbound rules.
To build a view with unbound rules we need to go through the following steps.
- Create a view as normal, in this case i am creating a view bound to a Smartbox SmartObject called ‘Customer Details’
- Don’t add a button assigned to a method. Just add the fields you want
- Click on ‘Rules’ and instead of clicking on a ‘Event’ like you would normally.
- Click on ‘Rule Name’ and enter in the following name ‘Unbound Save Data’
- Click on Conditions and select ‘View Passes Validation ‘ and select which fields are to be required.
- Click on Action and ‘Select view method create’
- We can then add some additional actions if we wanted too such as show a message or if it’s not valid show an error message.
- Click on ‘OK’ and then ‘Finish’
This is a very simple unbound rule, but we could do a lot more complicated rules if you wanted to.
Using the view with power of Unbound
Now that we have created this view with Unbound rules how we can put these rules into action, by adding it to a form.
- Create a new form as normal
- Drag the newly created view onto the form and any other views that you want
- Add a new button onto the form
- Click on ‘Rules’
- Select ‘When a form control raises an event’ from the ‘Events tab’
- Select the button from the select control link on the rule
- Click on the action tab and search for ‘Execute a rule’ and select the ‘Unbound Save Data’ rule
- You are now ready to test this rule.
Below is a video going through the full example with some additional rules
These views can be built to handle all the complex rules and then just be dragged on to any form and then choose when on the form to fire those rules. Leaving the form developer to just literally drag and drop without having to worry about any complex business rules on the form. Views allow for better use of standards being followed as we can have the library of views with all their rules predefined and they just need to be called, in the same way a developer would access methods of a library.
To me this opens up a new way of building applications instead of making views dummy containers or having rules that are bound to a button that is hidden on the view. We can how create really intelligent views, no we can create Smartviews.