Kbase 18924: ADM2 - How To Initialize Fields In An SDO On An Add
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  6/10/2005 |
|
Status: Unverified
GOAL:
How To Initialize Fields In An SDO On An Add?
FACT(s) (Environment):
Progress 9.x
FIX:
In the SmartDataObject's addRow function, add code similar to the following (completely replacing the standard behavior):
/* The following code assumes that you want to set the initial */
/* value of the "OrderNum" field in the "OrderLine" table to a */
/* default value of "99999". This same code can be used to do some */
/* more complicated field initialization than shown here (or than */
/* can be done in the Data Dictionary. */
DEFINE VARIABLE cReturnString AS CHARACTER NO-UNDO.
DEFINE VARIABLE iPosition AS INTEGER NO-UNDO.
/* Store the position of the "OrderNum" field in the list. If the */
/* field does not exist in the list then zero (0) is stored. */
ASSIGN iPosition = LOOKUP('OrderNum':U, pcViewColList).
/* Store the result of the "default" addRow() function so that we */
/* can modify the initial value. */
ASSIGN cReturnString = SUPER(pcViewColList).
/* Now that the list has been filled with the default initial */
/* values for all of the fields we will modify the field we are */
/* interested in. */
IF iPosition <> 0 THEN
ENTRY(iPosition + 1, cReturnString, CHR(1)) = '99999'.
RETURN cReturnString.
In the SmartDataObject's submitRow function, add code similar to the following (completely replacing the standard behavior):
/* Search the list of fields that have been modified and if the */
/* field we care about is not in the list add it to the list and */
/* put our default value in. This needs to be done because the */
/* is currently no way to put the initial value into the physical */
/* RowObject temp table record itself. */
DEFINE VARIABLE cNewRecord AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSource AS CHARACTER NO-UNDO.
DEFINE VARIABLE hUpdateSource AS HANDLE NO-UNDO.
{get UpdateSource cSource}.
hUpdateSource = WIDGET-HANDLE(cSource).
cNewRecord = DYNAMIC-FUNCTION('getNewRecord':U IN hUpdateSource).
IF cNewRecord = "ADD" THEN<
IF LOOKUP('OrderNum', pcValueList, CHR(1)) = 0 THEN
ASSIGN pcValueList = pcValueList + CHR(1) + 'OrderNum'
+ CHR(1) + '99999'.
RETURN SUPER(pcRowIdent, pcValueList).