Handling asynchronous and synchronous execution results
For the synchronous JSDO methods that do not execute Data Object operations (such as add( ) or find( )), the results for both successful and unsuccessful execution are as defined for each method. For more information, see the reference entry for the method in JSDO properties, methods, and events reference.
For methods that execute Data Object operations asynchronously (fill( ), saveChanges( ), and invocation methods), the results for each event or Promise are returned in a general request object that is passed as the last parameter to the event or Promise callback function. For invocation methods that you execute synchronously, a reference to this same request object is available as the return value of the method. This request object has a number of properties whose values depend on the event or Promise callback that returns the object. Some properties (including the jsdo, jsrecord, and success properties) duplicate the settings of the other parameters passed to the event or Promise callback. The settings of other properties provide additional information appropriate for the event or Promise callback. In addition, as of Progress Data Objects 4.3 or later, you can call the getErrors( ) method on a JSDO table reference in any callback to return errors associated with the table reference from the most recent call to fill( ) or saveChanges( ) (but not from a call to an invocation method).
One of the most important properties on the request object is the response property. This property is set only for the after* events of all Data Object operations. Depending on the type of Data Object (OpenEdge or Rollbase), it references JavaScript data that a Data Object operation returns for a successful or unsuccessful completion.
For a standard Data Object CRUD or Submit operation that completes successfully, this property references JavaScript that contains data for the returned single-table or multi-table resource converted from any valid JSON returned for the operation over the network. If no valid JSON is returned, this property is undefined.
For a custom Invoke operation that completes successfully, the response property references an object that contains properties with the values of any output parameters and return value of the server routine. For an Invoke operation on an OpenEdge resource, a property for an ABL output parameter has the same name (and letter case) as the corresponding output parameter, and has a JavaScript data type that maps to the ABL data type of the output parameter (see OpenEdge ABL to JavaScript data type mappings). Any return value from the routine is returned as the OpenEdge-defined property, _retVal, also with an ABL-mapped JavaScript data type.
For an OpenEdge Data Object operation that completes with one or more ABL errors, the response property references an error object that contains two OpenEdge-defined properties:
_retVal — A string with the value of any ABL RETURN ERROR string or ReturnValue property for a thrown AppError object.
_errors — An array of JavaScript objects, each of which contains properties with the ABL error message string and error number for one of possibly many ABL-returned errors.
For CUD or Submit operations on OpenEdge Data Object resources that support before-imaging, if the response property returns no error object, you can return any error messages stored with the before-image data for a record by calling the getErrorString( ) method on the record object. For more information, see the getErrorString( ) method description.
For a Rollbase Data Object operation that completes with an error, the response property is a simple string containing information about the error.
For any Data Object operations that complete with errors originating from the network, web server, or web application that hosts the Progress Data Object Service, you can inspect the xhr property on the request object to identify the error information. This property references the XMLHttpRequest object used to send and receive operation requests. For more information on this object, see the software development documentation for your web browser or mobile device.
For more information on the request object and its available properties, see the request object description.
Note that you can avoid any inspection of the response or xhr properties to return errors from calls to fill( ) or saveChanges( ) by calling the getErrors( ) method. This method returns all errors associated with a specified table reference, regardless of how they originated, whether from the resource operations themselves or from the network, web application, or web server that hosts the Data Object Service. For more information, see the getErrors( ) method description.