How to Set a Default Value for a Drop-Down List Control Populated by a SmartObject.


Userlevel 2
Badge +9

Please refer mainly to the following official documentation on how to achieve this design:


 


http://help.k2.com/onlinehelp/k2smartforms/UserGuide/current/default.htm#SF_-_ViewControls_-_Drop-Down_List.html#SmO_Def_Value


 


Scenario: You want your drop-down list control to automatically populate with a particular value when the view/form loads for a user.


 


How to do it:


The main change that we need to add is to the SmartObject that is being used as the data source for that particular Drop-Down List control. We will need to add in a boolean or Yes/No type property to that smartobject. This will be the flag on whether or not a particular value in this smartobject will be considered a default value. If it is default, that value will be dragged into the control upon the control initializing.


 


13329iD4FAA62303509A72.png


 


If we are adding this to a smartobject with existing values we are going to need to change the value of that particular row manually. This can be done via an update method on the desired value. Utilize the SmartObject Service Tester tool to do this. Or you can simply delete the old value and recreate a new one that contains True or Yes for the value in the Default column.


 


Now that the smartobject is set to deal with a default value and has that flag available, we need to tell the control what to do. Now we must go to the dropdown list control and under 'Properties' -> 'Data Source' we need to configure settings for the 'Type'. Please see below:


 


15510i551A0947A3832333.png


 


Now everything should be set to allow for this design to work properly. Save your form and run it to test. If you do not see this behavior check over the documentation provided that will give a more detailed and in depth explanation. 


 


0 replies

Be the first to reply!

Reply