1.0.1 • Published 6 years ago

@runmyprocess_sdk_js/sdk-js v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

JavaScript SDK version 1.8

The SDK contains useful JavaScript functions that help to communicate with RunMyProcess server resources.

Importing the JavaScript SDK on a Web Interface


In order to use the SDK it is necessary to import it to the Web Interface where it is required. The SDK can be imported in the JavaScript tab of the "Web Interface" editor window.

To add the SDK simply select it from the drop-down list in "JS Library".

SDK Import

This will import the SDK and its dependencies to the Web Interface. After importing the SDK the Web Interface must be saved.

SDK Import

The SDK functions will now be 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 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. Simply declare a new object of the resource you want to load

var user = new User();

and simply load it

user.load(options);

This 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 a 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 (in the example above user.id)