Solution #1 (Recommended):
Use the Describe() Evaluate function. In the following example the ddlb or dddw column is called state_code.
string rownumber,displayvalue
rownumber = string(dw_1.getrow())
displayvalue = dw_1.describe("Evaluate( 'lookupdisplay(state_code) ', "+rownumber+" )")
This solution does not require the definition of an additional
computed column on the datawindow. Note: This solution will not work in
the itemchanged event of the main datawindow. It must be done in an
event that occurs After the itemchanged event has completed by creating a
custom user event ON THE WINDOW mapped to pbm_customxx called
getdisplayvalue and then windowname.postevent (getdisplayvalue) from the
itemchanged event of the datawindow.
If you have several dddw columns or other columns, you may want to
use a choose case statement to have an action associated with each
column name.
CHOOSE CASE dw_1.getcolumnname()
CASE "state_code"
displayvalue = dw_1.describe("Evaluate( 'lookupdisplay(state_code) ', +rownumber+" )")
CASE "city_code"
displayvalue = dw_1.describe("Evaluate( 'lookupdisplay(city_code) ', "+rownumber+" )")
CASE ELSE
END CHOOSE
Solution #2:
1. Go into the Datawindow painter and add a computed column.
2. The
expression should be: Lookupdisplay(dept_id) where dept_id is the name
of your dddw column.
3. Name the computed column ‘display’.
4. Place
the computed column anywhere since we will make it invisible with
Modify().
5. Go into the window and add a user event called ue_lookup. In the script for this event code:
// displayvalue will contain the display value the user has selected from ddlb or dddw column
string displayvalue
displayvalue = dw_1.getitemstring(dw_1.getrow(),"display")
In the Itemchanged event for the main DataWindow (dw_1) code:
// check to see if the ddlb or dddw column is the correct one they are changing.
// use the column number (#) of the ddlb or dddw column.
if getcolumn() = 3 then
parent.event post ue_lookup()
end if
In the open event for the window add:
dw_1.modify("display.visible=0').
(This sets the computed columns visible attribute to "invisible".)