ui.Dialog.setFieldValue
Sets the value of a field controlled by the dialog object.
Syntax
setFieldValue(
name STRING,
value fgl-type )
- name is the name of the field, see Identifying fields in ui.Dialog methods.
- value is the value to be set, where fgl-type is one of the primitive data types.
Usage
setFieldValue()
method can be used when implementing a dynamic
dialog, to set the value of a field:DEFINE default_address STRING,
default_creadate DATE
...
CALL d.setFieldValue( "customer.cust_addr", default_address )
CALL d.setFieldValue( "customer.cust_creadate", default_creadate )
The first parameter defines the field to be set.
In a dynamic dialog controlling a list of records (INPUT ARRAY
/
DISPLAY ARRAY
), this method sets the value for a field in the current
row. To fill the list of records before dynamic dialog execution, use setCurrentRow()
to set the current row, then set field (cell values) with setFieldValue()
.
During dialog execution, the setFieldValue()
method must only be used to set the
value of a field for the current row. In a regular dynamic list dialog, calling the setCurrentRow()
method to change
the current row before calling setFieldValue()
will have no effect. However, when
the ON FILL BUFFER
event occurs in a DISPLAY ARRAY
using the
paged mode, the
setCurrentRow()
method must be used to set the current row before calling
setFieldValue()
for each field to fill the data page. In this context, a
setFieldValue()
will produce error -8129, if the current row is not
part of the visible page. In a DISPLAY ARRAY
using the full list mode, the error -8129 is raised, if
there is no current row (when the array is empty).
Example
The following code example implements a FOR
loop to copy values of
all fields of the d_disparr
dialog to the field of the
d_recinp
dialog:
DEFINE row, i INTEGER,
h base.SqlHandle,
fields DYNAMIC ARRAY OF RECORD
name STRING,
type STRING
END RECORD,
d_rec ui.Dialog,
d_list ui.Dialog
...
-- Fill the array with rows from an SqlHandle object
CALL h.open()
LET row = 0
CALL h.fetch()
WHILE status == 0
-- must set the current row before setting values
CALL d_list.setCurrentRow("sr_custlist", row:=row+1 )
FOR i = 1 TO h.getResultCount()
CALL d_list.setFieldValue( h.getResultName(i), h.getResultValue(i) )
END FOR
CALL h.fetch()
END WHILE
CALL h.close()
CALL d_list.setCurrentRow("sr_custlist", 1)
...
-- Copy field values from d_list to d_rec dialog
FOR i=1 TO fields.getLength()
CALL d_rec.setFieldValue( fields[i].name,
d_list.getFieldValue( fields[i].name )
)
END FOR