Select properties for a customer

  • 6 August 2012
  • 7 replies
  • 1 view

Badge +2

First, let me say that I'm very new to K2, and I'm trying to self-study this, so bear with me...


I'm trying to create a form (or view) that will be step two in a customer creation. Step one was making the customer. Easy enough. In step two, there should be a readonly field with the customer name, and two lists. One containing all the possible properties I can assign to him, and one with the properties I've selected, and between the two lists there should be Add and Remove buttons.


Is there an easy way to do that?


I've made a list (with create possibilities) for the properties already.


I hope someone can help


Thanks in advance!


7 replies

Badge +3

 


Hi elveejay


As I understand, you are looking for functionality
resembling that of a “List box” control found in VB/C#/etc. This behaviour can
be mimicked as described in the following example.



In this scenario I will be using the following
SmartObject configuration:



Comparing this to your setup, you would have x2 Forms. 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]



 


Please let me know if this resolves your issue.


 


Representation of runtime behaviour (download/open the below gif image in a new tab):



 

Badge +2

Thank you. That was exactly what I needed.


I'm still quite new to K2 - is it possible to attach the files of this little project to this thread so I can study every little detail?

Badge +3


Hi elveejay


Unfortunately I cannot currently send you my solution (including Views/Forms) as it will require copying multiple values from multiple places in the smartforms DB's. 


We are however currently working towards releasing a tool, called 'Package and Deployment', which would make this possible. This would most likely ship with some future release of K2, although nothing is certain yet as the tool is still in its early test phases.


At this stage I cannot comment or speculate when this tool will be available.


Badge +2

Ok...then I'll just have to see it as another challenge ;-)


I have run into another problem, however. When I delete something from the left list, it also gets deleted from the table behind it. Thus, when I open the form next time, there will be less objects to choose from.


Is it possible to sort detach it from the table behind?


In my own code, I have some  columns that will not be transferred to the equivalent "UserSkill" list, and will thus be lost once transferred. That also led me to another thought: can I have hidden columns in a table? I suppose I could just make another view with less columns, but sometimes it would be nice to be able to hide things for one reason or other.


I'd also like to thank you for your time. It's great that there are people like you out there in cyberspace who are willing to help others :-)

Badge +3


Hi elveejay


I'm glad that I could be of assistance :) . As for your newly posted questions...


The reason why the data is being removed from the backend is most probably due to a Rule Action which was generated to do so. In all likely hood it is residing within the following Rule Event:


- When the View executed List item removed


The culprit would be this following Rule Action:


- then execute the Delete for all the items that have been Removed


Due to the above mentioned configuration (as mentioned in my example), there should actually be no need for this entire Rule, and you can simple delete the entire Rule from the View.


Furthermore, it is indeed possible to hide a column. Please note however, that a column in a List View consists of three areas:


1) Column


2) Header


3) Body


In order to hide the entire column, you would have to set the 'Visible' property of the "Column" tab to 'False'.


Badge +2

Hm...I've looked both at the view and at the form now...there's only a "When the view initializes" rule, and some execution of GetList.


Are there some hidden rules or something?

Badge +2

After a lot of fighting the system, I seem to've got it working, even if my rules section differs somewhat from yours.


 


But now I got another tricky problem: I also want to edit the person I created previously. When I enter the Form again, this time in "edit mode" so to speak, the list of available skills must be filtered so as to exclude the skill the person being edited already have. Sort of a


"Select * from skills where skill_id not in (select skill_id from UserSkills where UserID = <user id being edited>)"


Can that be done?


 


I've also noticed, that sometimes when I try to edit rules, some of them can't be reconfigured or removed. Is that just a bug in K2, or am I doing something wrong? Some of the rules also get cleared when I try to edit the configuration, which means that I don't just have to add the single new field to a configuration, but instead have to add *all* fields again. I think it's a bug...but it might be a feature I'm not familiar with ;-)

Reply