JavaScript SDK
The SDK contains useful JavaScript functions that help to communicate with RunMyProcess server resources.
Importing the JavaScript SDK to a Web Interface
In order to use the SDK it is necessary to import it to the web interface where it is required.
Proceed as follows:
- In the WebModeler of DigitalSuite Studio, open the Settings of the web interface.
- On the JS tab, click the plus icon to add an existing JS.
- In the dialog displayed, select Standard Libraries.
- Select the library of the required SDK version in the list.
- Confirm your entries. This will import the SDK and its dependencies to the web interface.
- Save the web interface.
The SDK functions are now available.
Note: The SDK is a client side application, so the browsers cache must be emptied when adding, deleting, or changing the SDK version.
Using The SDK-JS
The objective of the SDK-JS is to:
- Simplify JavaScript interaction with the server.
- Reduce code complexity.
- Reduce user programming knowledge requirements.
- Make JavaScript code more intuitive.
To accomplish this, various functions were built in the SDK-JS to load, save, update, and delete resources in RunMyProcess.
Loading Resources
Loading resources is quite simple. Just declare a new object of the resource you want to load
var user = new User();
and load it
user.load(options);
The load function will formulate a GET request to the server asynchronously and set all required values in the user resource. You may have noticed that the load function expects an object which we have named "options". Through this "options" object we will pass an "on success" callback function, an optional "on failure" callback function, and an optional base url (if for some reason we wish to use a different base url).
So the full request will look something like this:
var user = new User();
var options = {};
options.onSuccess = function(){
alert("The user "+user.id+" was loaded");
};
options.onFailure = someErrorCallbackFunction(error);
user.load(options);
The requested information will be set before calling the callback function, so you may access all the information on your callback (user.id in the example above).