JS Software Development Kit

JS Software Development Kit

Overview

JS APIs are JS functions to include various ServiceDesk Plus MSP Cloud functionalities into the custom widget you create.
Add this JavaScript file to all the HTML/widget pages to access the JavaScript APIs from the application: https://sdpondemand.manageengine.com/scripts/v1/widget/sdpclientsdk.min.js. 

The JS file must be loaded into every widget page where you want to invoke the APIs. Use the following syntax to add the JS file to the widget pages:

Syntax:
  1. <script type="text/javascript" src="https://sdpondemand.manageengine.com/scripts/v1/widget/sdpclientsdk.min.js"></script>
Info
  Note: Software Development Kit is available only for Enterprise users.  

JavaScript API  

While developing a custom widget, you can use JS API functions to invoke calls to your widget or any third party applications. This page documents the various functions that you can use to build your custom widget and their use cases.
Info
JS  API functions must be invoked  from widget, outside the widgets JSON array

General Functions for Custom Widgets 

SDP.init() 

Initializes the JS SDK and defines utility functions by establishing the connection between the product and the custom widget. This function acts foundational to establish connection between the custom widget and other JS APIs to make them visible to users. Other JS APIs will be defined only when the initialization is completed.

Returns:
Promise - Resolved with API Success or Rejected with API Failure

Syntax:
  1. SDP.init().then(function(response) {
  2. console.log(response);
  3. }).catch(function(response) {
  4. console.log(response);
  5. });
 
Sample:
API Call
Success Response
SDP.init().then(function(response) {
console.log(response);
}).catch(function(response) {
console.log(response);
});
{
    "meta": {
        "module": "header",
        "instance": {
            "appid": "709641411",
            "appname": "widgetdev",
            "appdisplayname": "Widget Development"
        },
        "personalization": {
            "time_zone": "Asia/Kolkata",
            "time_format": "MMM d, yyyy hh:mm a",
            "date_format": "MMM d, yyyy"
        },
        "userLanguage": "en",
        "userLocale": "en_US",
        "userType": "Technician",
        "userId": "120747000000232217",
        "userName": "Widget Development",
        "userEmail": "widget_dev@sdpdev.onmicrosoft.com",
        "isSDAdmin": true,
        "widget": {
            "id": "120747000002587069",
            "name": Custom Widget",
            "description": "",
            "custom_widget": {
                "id": "120747000002587067"
            }
        }
    },
    "uniqueID": "78d261d9-65f7-48bc-b10d-84b7e79b1285",
    "location": "webtab"
}
 

SDP.invokeUrl(options) 

Fetch data from integrated third party applications. The function is mapped under various option params such as URL, method, headers, params, payload, file-id, connection pathway (connection link). You can invoke 3rd party URLs directly or by using connections. By default, 3rd party URLs are invoked directly if connection is not set.

Parameters:
Name
Type
Description
options*
Object
Object which contains API details.

Property
Type
Description
url*
String
Indicates the API URL. Encode the URL if it contains space.
method
String
Indicates the method of the API call. By default “post” method is passed.

Supported methods: get, post, put, delete, and patch.
params
Object
Indicates the params of the API in key value format.
headers
Object
Indicates the params of the API in key value format.
payload
String
String to be passed in Request Body.
is_connection
Boolean
If set as true, connection is established. Used to connect to Intranet sites or to establish connection between Cloud and On-premise applications.
connectionLinkName
String
Specify the DRE connection link name. Only connections that are installed in the custom widget package can be used here. This will be considered only if “is_connection” property is not true.
file_id
Long
Indicates ServiceDesk Plus MSP Cloud File ID. This option is used if an attachment needs to be uploaded to the third party application. This property is supported only when the “connectionLinkName” is provided.
 
* - Mandatory parameter
Info
You cannot configure DRE connection to invoke a third party application.

Returns:
Promise - Resolved with API Success or Rejected with API Failure.

Syntax:
  1. SDP.invokeUrl(options).then(function(response) {
  2. console.log(response);
  3. }).catch(function(response) {
  4. console.log(response);
  5. });
 
Sample:
API Call
Success Response
Failure Response
SDP.invokeUrl({
“url”: “https://api.twitter.com/1.1/statuses/update.json”,
“method”: “post”,
“params”: {
“status”: "SDP and twitter integrated"
},
“connectionLinkName”: “twitter”
}).then(function(response) {
console.log(response);
}).catch(function(response) {
console.log(response);
});
//Based on 3rd party API
//Based on 3rd party API