Issue

The following or similar error might occur when trying to transfer a value into the Picker control and the type of the value does not match the type of the Identifier.

Image

The behavior of the Picker control has changed in K2 smartforms 1.0.4. Values can no longer be transferred to the Picker control that do not match the Identifier’s type. Subsequently in K2 smartforms 1.0.6 a load and resolve method were added to setup parameters and filtering on top of the standard Picker control behavior

Background Information

The Identifier is what is used to store the value behind the scenes and ties directly into the get and set methods of the control.

Image

In K2 smartforms 1.0.4 the behavior of the Picker control was changed so that when values are transferred to the Picker control only the correct value will be loaded

Previously (in K2 smartforms 1.0.3) incorrect values could be loaded that matched a subset of the value transferred for example:

If the list of values that the Picker control was bound to was;

  • 100
  • 10

And a value of 10 was transferred to the Picker control the order of the list values will determine whether 10 or 100 is resolved. If 100 is listed in the data before 10 then 100 would load as it matches “10”, otherwise 10 would load.

Similarly:

If the list of values that the Picker control was bound to was;

  • Bobby
  • Bob

And a value of Bob was transferred to the picker the order of the list values will determine whether Bob or Bobby is resolved. If Bobby is listed in the data before Bob then Bobby would load as it matches “Bob”, otherwise Bob would load.

To resolve this, the Picker control was changed to do an “equals” query only on the Identifier field and as a result type checking was added before the query is executed. If the type is incorrect the Picker control will show an error message at runtime.

Workaround

The following options can be applied to resolve the issue:

K2 smartforms 1.0.4 or later

  1. Change the solution so that it uses the Picker control correctly, i.e. the type of the value transferred should match the type of the Identifier.
  2. Apply the web.config change to revert the Picker control to the old behavior (as applicable in K2 smartforms 1.0.3). This workaround is not advised as explained in the Background Information

Not recommended:

To revert the Picker control to the K2 smartforms 1.0.3 behavior, add the appsetting Forms.Controls.Picker.SetValueUseContains to the web.config and set it to true

Recommended:

The recommended approach is to correct the Identifier field. A common mistake would be to leave the Identifier on ID when it should be FullName or some other field. Existing data may contain names which would have loaded correctly in K2 smartforms 1.0.3 provided that the names where unique and not a subset of other names. If the Picker control was used to save the data then the ID would be saved and not the FullName.

To resolve the above common scenario in K2 smartforms 1.0.4 or later simply adjust the Identifier for the Picker control to FullName and this will ensure correct execution.

K2 smartforms 1.0.6

A Load and Resolve method have been added to setup parameters and filtering on top of the standard Picker control behavior.

Image

The Load method feature functions the same as a “transfer” action however it will always load regardless if the control value is already the same firing the change event.

The Load method is used for dependent drop-downs (with Picker controls). A rule is automatically configured for the Load method where dependent Picker controls are used.

The Resolve method will resolve the values as if they had been typed in and will build a query against all the selected filters instead of just on the identifier column.

The Data Source of the Picker control can also be configured to use another control’s value as shown below.

Image

See the Picker control topic in the K2 smartforms Online Help for more information.