Monday, 13 August 2012

In this example I constructed an entire scenario in order to add some scope to the demo, a lot of this scope is not necessary. The scenario consists of creating a new User, and assigning Skills to that particular User. We will be creating the user on Form_1, where after we will do the Skill assignments on a second Form to which we will navigate.

I will be using the following SmartObject configuration:

On your first Form, you will create/add a new User. Thereafter you will navigate to the second Form, in order to specify the Skills of that User, but we would need context of the User created/added on Form_1. As such, we’ll add a Form Parameter of type ‘Integer’ to Form_2 (this is simply to ensure that we always work with the correct context):


Then, when navigating to Form_2, we will need to transfer the ID of the User which we just created, to the Parameter created in the steps above:


In my example I used an Item View built on the User SmartObject in order to display the data of the specific user (but you should be able to user Form level controls as well). You will then need to configure the following Rule in order to display the data of the User:


The layout of Form_2 will need the following objects:
·         An ‘Item View’ (as described above)
·         An ‘Editable List View’ built on the “Skill” SmartObject
  o   This View will need the following columns:
+  Name
+  ID (this column should be hidden)



·         An ‘Editable List View’ built on the “UserSkill” SmartObject
  o   This View will need the following columns:
+  Skill_ID


·         X2 [Button] controls:
  o   ‘Add button’
  o   ‘Remove button’


At the end of the day, the layout will resemble something like this:

To support the desired behaviour, we will need to configure Rules to essentially do the following…
1)      Add a new row to the destination View
2)      Transfer the data from the source View to the destination View
3)      Apply the changes made to the destination View
4)      Remove the row from the source View
5)      Apply the changes made to the source View
6)      Disable the button which made the transfer (for logic validation)

The tricky part is to transfer the data correctly.

When transferring the data to the ‘UserSkills’ View we will transfer the “ID” SmartObject field of the SmartObject associated with the ‘Skills’ View, to the [DropdownList] control of the ‘UserSkills’ View.


When transferring the data to the ‘Skills’ View we will transfer both the “Skill.ID” and “Skill.Name” from the SmartObject associated with the [ListDisplay] control on the ‘UserSkills’ View, to the “Name” and “ID” [Textbox] controls available on the ‘Skills’ View.


As such, the Rules will look as follows:

[Add Button]

[Remove Button]

If everything was configured correctly, the runtime behaviour for the above created scenario should look something like this:

1 comment:

  1. Nice article, this method works great for a project that I'm working on, but I can't figure out how to not load "Available skill" that are already choosen as skills next time I want to add/remove skill for current user. Do you have some solution for that?

    ReplyDelete