Giving views the power in K2 Smartforms

Introduction

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.

IMG_0020

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.

  1. Create a view as normal, in this case i am creating a view bound to a Smartbox SmartObject called  ‘Customer Details’
  2. Don’t add a button assigned to a method. Just add the fields you want
  3. Click on ‘Rules’ and instead of clicking on a ‘Event’ like you would normally.
  4. unbound-setup1
  5. Click on ‘Rule Name’ and enter in the following name ‘Unbound Save Data’unbound-newrule
  6. Click on Conditions and select ‘View Passes Validation ‘ and select which fields are to  be required.
  7. Click on Action and ‘Select view method create’unbound-setup2
  8. 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.
  9. 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.

  1. Create a new form as normal
  2. Drag the newly created view onto the form and any other views that you want
  3. Add a new button onto the form
  4. Click on ‘Rules’
  5. Select ‘When a form control raises an event’ from the ‘Events tab’ unbound.form.button
  6. Select the button from the select control link on the rule
  7. Click on the action tab and search for ‘Execute a rule’ and select the ‘Unbound Save Data’ ruleunbound.form-2
  8. You are now ready to test this rule.

Below is a video going through the full example with some additional rules

Conclusion

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.

One thought on “Giving views the power in K2 Smartforms

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s