Consultor Eletrônico



Kbase 34374: How to initialize a SmartSelect field to a default value when adding a new record.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Solution ID: P4374

GOAL:

How to initialize a SmartSelect field to a default value when adding a new record.

FIX:

The following sample code shows how to initialize a SmartSelect field to a default value when adding a new record:


/*-------------------------------------------------------------------------*/
/* Purpose:     Super Override of displayFields in the SDV containing the */
/*              SmartSelect. */
/* Parameters:   */
/* Notes:        */
/*-------------------------------------------------------------------------*/

DEFINE INPUT PARAMETER pcColValues AS CHARACTER NO-UNDO.

/* Code placed here will execute PRIOR to standard behavior. */

DEFINE VARIABLE cNewValue  AS CHARACTER  NO-UNDO INITIAL "My New Name".
DEFINE VARIABLE iPosition  AS INTEGER    NO-UNDO.
DEFINE VARIABLE cNewRecord AS CHARACTER  NO-UNDO.
DEFINE VARIABLE cColList   AS CHARACTER  NO-UNDO.

cNewRecord = DYNAMIC-FUNCTION("getNewRecord":U).

IF cNewRecord = "Add":U THEN
DO:
    ASSIGN cColList = DYNAMIC-FUNCTION('getDisplayedFields':U)
      iPosition = LOOKUP('name':U, cColList).

      IF iPosition <> 0 THEN
        ENTRY(iPosition + 1, pcColValues, CHR(1)) = ENTRY(1, cNewValue).
END.

 RUN SUPER( INPUT pcColValues).

/* Code placed here will execute AFTER standard behavior.    */

END PROCEDURE.