afterSaveChanges event
- Last Updated: May 9, 2017
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Fires once for each call to the saveChanges( ) method on a JSDO, after responses to all
create, update, and delete record requests sent to a Data Object resource have been
received from the server.
This event fires after all responses have been received from one or more Create, Update, and Delete (CUD) operation requests (sent without using Submit), and fires after the one response has been received from a single Submit operation request after its one or more record changes have completed.
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
Syntax
The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:
|
- jsdo
- A reference to the JSDO that invoked the
saveChanges( )method for one or more record changes on its resource. For more information, see the description of the jsdo property of the request object. - success
- A
booleanthat istrueif all record changes invoked on the resource bysaveChanges( )were successful. For more information, see the description of the success property of the request object. - request
- A reference to the request object returned after the
saveChanges( )method completed execution and returned all results from its record changes on the server. For more information, see the description of the 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, onAfterSaveChanges, to handle the afterSaveChanges event fired on the JSDO, myjsdo, for changes saved on an OpenEdge single-table resource, ttCustomer without using a Submit operation:
|
If successful, the example loops to display the data from every record in JSDO memory (not
shown). If unsuccessful, the example loops through the array of error objects returned from
the call to saveChanges( ) (the result of calling jsdo.ttCustomer.getErrors( )) and logs annotated values for
each error object returned, depending on its type (errors[idxError].type).
If a record ID is included for a given error object, you can display the field values for
the associated record (not shown) that you can return from
request.batch.operations[index].jsrecord, where index
identifies a returned request object for an operation in the
request.batch.operations array and the error record ID matches getId(request.batch.operations[index].jsrecord).
autoApplyChanges property (true), which automatically accepts or rejects changes to JSDO memory based on
whether all CUD operations were successful. Note also that for an unsuccessful result, the
error information returned by getErrors( ) is still
available until the next invocation of fill( ) or saveChanges( ).See also:
beforeSaveChanges event, saveChanges( ) method, subscribe( ) method (JSDO class), unsubscribe( ) method (JSDO class)