How to add items with dual values on a combo box

How to add items with dual values on a combo box

This tutorial show you how to create an item on a combo box that implements two values, one will be the key value of the item and the other would be the description of the item. You can achieve this by creating a custom API function to add the items to the combo box, please follow these instructions to create and implement that API function.
  1. Create these fields on Plex:
    a) Control+

    b)
     Method_




    c)
    InternalValue


    d)
    ExternalValue





  2. Create a new source code object called “AddComboValue” and add these parameters: 

    ·         FIELDS/Function

    ·         FIELDS/Control (Will contain the control name of the combo on which the new item will be added)

    ·         FIELDS/Method

    ·         FIELDS/Param1

    ·         FIELDS/Param2

    ·         FIELDS/Param3

    ·         FIELDS/Param4

    ·         FIELDS/Param5

    ·         FIELDS/RetValue

    ·         InternalValue (contains the key value of the new item)

    ·         ExternalValue (contains the description of the new item)



  3. Add this code to your “AddComboValue”  source code object:

    Object x = new Object();

    ObComboData myobj = (ObComboData)ObUserAPI.callMethod(getFunction(), &(1:), &(2:), &(3:), &(4:), &(5:), &(6:), &(7:), &(8:), x);

    myobj.addValuePair(&(11:).getValue(), new ObCharFld(&(10:).getValue()) );

  4. Open the Action Diagram from your function that uses the combo box and add the following fields on any of your local variables:

    ·         Control+

    ·         Method_

    ·         FIELDS/RetValue

    ·         InternalValue

    ·         ExternalValue





  5. In the Action Diagram, to add a new item on the combo box you just need call your “AddComboValue” source code after set the values of the fields “Control+”, “ExternalValue” and “InternalValue”.

    Example:


    For the values of the other parameters please use the same values we defined in the following image


    NOTE: REMEMBER that the value of the “Control (Control+)” parameter must be the same value of the control name from the combo box in your function, otherwise the API function cannot find the control on which the new item must be added. In our test function we configured the control name with the same value of the “name” triple assigned to the field that we used as combo box, this way we can use the “Name” statement in the Action Diagram to set the same value of the control name in the “Control” parameter, please see the following images to see how we used this, remember that this is just an example and you can use any other method to achieve the same result:






  6. Generate your function and test it: