How to pass a value into a Form to set the value of a drop-down control.

  • 27 June 2016
  • 0 replies
  • 10 views

Userlevel 3
Badge +10


 

Symptoms

 


How to pass a value into a Form to set the value of a drop-down control.
 

 

Diagnoses

 


The form was not executing the Initialize rule of the view that loads the drop-down.
 

 

Resolution

What you can do is to pass values in via the Query String using the name of a Parameter that has been created on the Form. I.e. https://k2server/Runtime/Runtime/Form/MyForm/?Param1=a&Param2=b

This will initialize those parameters with the values you pass in. Now the tricky part is regarding the drop-down's configuration. If its Data Source -> Value field (not Display) is set to ID, you will need to pass in an ID to set the currently selected row. Additionally, if the Value field is set to a non-unique SmartObject field, it will select the first one it finds in the drop-down.

Here are the rules involved in setting this up:
Add a 'When the Form is Initialized' event, an 'If a Form parameter has been specified' condition, and a 'Transfer Data' action, transferring the value of the passed-in parameter into the drop-down. Assuming the value is present in the list, it will pick the first one it finds.

Relevant documentation below:

Query String parameters:
http://help.k2.com/kb001351

Drop-down List control:
http://help.k2.com/onlinehelp/K2Appit/UserGuide/current/default.htm_SF_-_ViewControls_-_Drop-Down_List.html

 

 



 

0 replies

Be the first to reply!

Reply