$customHeader
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

When you want the data from a Service Data Object and you're working in JavaScript, the Aptify JavaScript API provides a handy interface.

Step-by-step guide

  1. Know the Name of the Service Data Object.

    var getPILQuantityDataObject = "spGetProductInventoryLedgerQuantities";
    
  2. Know the parameters you need and their values.

    var getPILQuantityParams = {
    	"ProductInventoryLedgerID": 1
    };
  3. Define success and error callback functions. Of course, you can define these anonymously in the actual call to executeDataObject(), but that call will be more succinct and readable if you define them separately.

    Define A Success Callback
    function _onGetPILQuantitySuccess(data) {
    	// data.results contains the table produced by the Service Data Object
        // The table is represented as a 0-indexed array of rows.
        // A row is represented as a JavaScript Object with properties 
    	// that have the names of the columns returned by the Service Data Object
    	if (data && data.results.length > 0) {
    		// Handle each row of the table
    	}
    } 
    Define An Error Callback
    function _onGetPILQuantityError(error) {
    	throw ({ type: "internal_error", message: "An error occurred while calling " + getPILQuantityDataObject + " Service Data Object." });
    }
  4. Call Aptify.framework.dataObjects.executeDataObject() to execute the Service Data Object.

    Best practice is to check that Aptify Web is actually online before making the call, since the Service Data Object is executed on the server side.

    Execute A Service Data Object
    if (Aptify.framework.utility.online()) {
    	Aptify.framework.dataObjects.executeDataObject({
    		name: getPILQuantityDataObject,
    		parameters: getPILQuantityParams,
    		successCallback: _onGetPILQuantitySuccess,
    		errorCallback: _onGetPILQuantityError
    	});
    }
    else {
    	// Handle offline condition
    }

 

  • No labels