ui.Dialog.setFieldValue

Sets the value of a field controlled by the dialog object.

Syntax

setFieldValue(
   name STRING,
   value fgl-type )
  1. name is the name of the field, see Identifying fields in dialog methods.
  2. value is the value to be set.

Usage

The 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().

Important:
  • During dialog execution, the setFieldValue() method must only be used to set the value of a field for the current row. Calling the setCurrentRow() method to change the current row before calling setFieldValue() will have no effect.
  • In a DISPLAY ARRAY using the paged mode (ON FILL BUFFER), 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
    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 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