JSDO properties, methods, and events reference : beforeSaveChanges event
  

beforeSaveChanges event

Fires once on the JSDO before a call to the saveChanges( ) method sends the first request to create, update, or delete a record in its Data Object resource on the server.
This event fires before the first of possibly multiple Create, Update, and Delete operation requests are sent without using Submit, and fires before the first one of possibly multiple record changes are sent with a single Submit operation request.
Note: A single Create, Update, or Delete operation request is sent for each record object that you have created, updated, or deleted (respectively) 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
The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:

Syntax

function ( jsdo , request )
jsdo
A reference to the JSDO that is about to invoke the saveChanges( ) method for one or more record changes on its resource. For more information, see the description of jsdo property of the request object.
request
A reference to the request object before the first record-change request is sent to the resource. 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.

Example

The following code fragment subscribes the function, onBeforeSaveChanges, to handle the beforeSaveChanges event fired on the JSDO, myjsdo, where myid is the known ID of a record to find and process for resource operations being sent to the server:
/* subscribe to event */
myjsdo.subscribe( 'beforeSaveChanges', onBeforeSaveChanges );
    
/* some code that initiates multiple CUD requests and
   sends them to the server */
var newrec = myjsdo.add();
var jsrecord = myjsdo.findById(myid);
if (jsrecord) {jsrecord.remove();};

. . .

myjsdo.saveChanges();
    
function onBeforeSaveChanges ( jsdo , request ) {
    /* code to execute before sending first (or only) request to the server */
};

See also:

afterSaveChanges event, saveChanges( ) method, subscribe( ) method (JSDO class), unsubscribe( ) method (JSDO class)