JSDO properties, methods, and events reference : beforeUpdate event
  

beforeUpdate event

Fires before the JSDO, by means of a saveChanges( ) call following an assign( ) call, sends a request to update a record in the Data Object resource on the server.
This event fires before each Update operation request is sent without using Submit, and fires before each one of possibly multiple record updates are sent with a single Submit operation request.
Note: A single Update operation request is sent for each record object that you have updated in the JSDO with a single call to saveChanges( ) or saveChanges(false). A single Submit operation request for any and all created, updated, and deleted JSDO record objects is sent with a single call to saveChanges(true).
Applies to: progress.data.JSDO class, table reference property (JSDO class)
The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:

Syntax

function ( jsdo , record , request )
jsdo
A reference to the JSDO that is invoking the update request. For more information, see the description of jsdo property of the request object.
record
A reference to the table record upon which the update request is about to act. For more information, see the description of jsrecord property of the request object.
request
A reference to the request object before the update request is sent. For more information, see the description of request object.
Application code can subscribe a callback to this event by invoking the subscribe( ) method on a JSDO instance or one of its table references.

Example

The following code fragment subscribes the function, onBeforeUpdate, to handle the beforeUpdate event fired on the JSDO, myjsdo, created for a single-table resource, where myid is the known ID of a record to find and update. In this case, the onBeforeUpdate event callback assigns additional data to the updated record before sending it to the server:
/* subscribe to event */
myjsdo.subscribe( 'beforeUpdate', onBeforeUpdate );

/* some code that might update one or more
records and save them on the server */
var jsrecord = myjsdo.findById(myid);
if (jsrecord) {jsrecord.assign( { myField1 = myvalue, myField2 = myvalue2 } );};

. . .

myjsdo.saveChanges();
    
function onBeforeUpdate( jsdo , record , request ) {
    /* for example, here you might update data in the record
       further before it is sent to the server */
    record.assign( { myField4 = myvalue4, myField5 = myvalue5 } );
};

See also:

assign( ) method (JSDO class), afterUpdate event, saveChanges( ) method, subscribe( ) method (JSDO class), unsubscribe( ) method (JSDO class)