Consultor Eletrônico



Kbase 18413: ADM2. How to Add a Record to a SmartDataObject w/o a SmartPanel
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Verified

GOAL:

How to add a record to a SmartDataObject (SDO) without using an Update SmartPanel using the addrow and submitrow functions

FACT(s) (Environment):

Progress ADM2
Progress 9.x

FIX:

This example will add a record to a SmartDataObject for the Customer table in the sports2000 sample database. It does not use a visualization SmartObject to get the data for the new record. It uses fill-in fields on the SmartWindow to get the data from the user for the new record.

1) Create a SmartDataObject for the Customer table.

2) Drop the SmartDataObject onto a SmartWindow with fill-in fields for the Customer Name and EmailAddress fields.

3) Create a button on the SmartWindow with the following trigger code:

ON CHOOSE OF btnAddRec DO:
DEFINE VARIABLE newRec AS CHARACTER NO-UNDO.
DEFINE VARIABLE newRecValues AS CHARACTER NO-UNDO.

newRec = ENTRY(1,DYNAMIC-FUNCTION('addRow':U IN h_dcustomers,
INPUT ""),CHR(1)).
newRecValues = "Name" + CHR(1) + cName:SCREEN-VALUE + CHR(1) +
"EmailAddress" + CHR(1) + cEmail:SCREEN-VALUE.

IF DYNAMIC-FUNCTION('submitRow':U IN h_dcustomers,
INPUT newRec,
INPUT newRecValues) = FALSE THEN
MESSAGE "Submit was not successful".

END.

The addRow function will create a RowObject temp-table record in the SmartDataObject and will return a list of ColumnName/Value pairs to be displayed for the fields (which are not needed for this particular example).
The submitRow then accepts the list of changed values for the row and assigns them to the RowObject temp-table, returning FALSE if an error occurs.