Friday 30 October 2015

Multi select lookup on form field

We have ready-to-use lookups in system.
Unfortunately we can choose only one item from such lookup.
What if we need to select more than one element?

We have to use class SysLookupMultiSelectCtrl

I've prepared an example how to use this on AOT form, but there is no issue to use it on dialog field from SysOperation Framework.
You must remember that it can be used when dialog is already build, so on SysOperation framework it can be used on method postBuild or postRun.

It's not so easy to use it on RunBase classes or when you're trying to build, because you have to overload a method lookup for that dialog field. Overloading method can be done only once, and this SysLookupMultiSelectCtrl is overloading it once again, it cause runtime errors.
If you really need to have such multilookup on Runbase dialog you have to copy some pieces of code from SysLookupMultiSelectCtrl and overload lookup method.

So....this example is for form fields, and last line from init method can be transfered to postBuild() method on SysOperation framework to UIBuilder class.

I've created very simple form with one field ItemId



I've changed two properties on that field
Autodeclaration: Yes
ExtendedDataType: ItemId

You don't have to put EDT on this form control. You'll receive multilookup anyway.
I've used EDT to have proper label, help text and size of that control.

Remember that EDT ItemId has limitation of lenght, so it may be not long enough to store more than 1-2 item Ids! It's just an example

You have to modify three method on form

classDeclaration




init



close



Instead of modifying close method, you can add some button on our form.
I'm using close method to catch value from our ItemId control and display this value.

This is how our lookup looks like


When we press OK on lookup, we will get chosen values to our field



After form closing, we will receive a message with chosen values.