Sunday, January 10, 2010

List Items Default Value from Database

If you want to provide a default value for Poplist you just set its initial value property to the desired value. But if you want to retrieve the value from database then what is the procedure?

Long days have passed I’m trying to solve this problem. I’ve search on the internet but no article or forum said exactly what I want. Today I’ve solved the puzzle. I’m describing the procedure bellow:

  1. Create a Item and change its Item Type property to List Item
  2. Set its List Style property to Poplist
  3. Give a dummy value to its Elements in List property
  4. Give its Initial Value property by a global Variable (i.e.:GLOBAL.VAR_NAME)
  5. Create form level trigger WHEN-NEW-FORM-INSTANCE and write a query to retrieve the initial value from database and store it to the global value
  6. Populate the list from database query.
  7. Enjoy!

2 comments:

  1. You can use PARAMETER instead of GLOBAL variable.

    01. Create a parameter :PARAMETER.PARAM_NAME
    02. Set items initial value by the parameter
    03. Query initial value and store it to parameter

    Thanks!

    ReplyDelete
  2. You can also use control item instead of control (non-database)item

    01. Create a control item :CONTROL.ITEM_NAME
    02. Set items initial value by that control item
    03. Query initial value and store it to control item

    Thanks!

    ReplyDelete