Fetch Custom Widget/User Details

Fetch Custom Widget/User Details

SDP.getCurrentInstance();

Fetches the details of the instance where the custom widget is loaded.

Returns:
Object – Returns instance details object.

Syntax:
  1. var instanceDetails = SDP.getCurrentInstance();
 
Sample Response:
  1. {
  2.    appdisplayname: "IT Desk"
  3.    appid: "15459854"
  4.    appname: "itdesk"
  5. }
 

SDP.getCurrentUserId(); 

Fetches the logged-in user ID.

Returns:
String – Returns userId as a string.

Syntax:
  1. var userId = SDP.getCurrentUserId();
 
Sample Response:
  1. "100000000000032197"
 

SDP.getCurrentUserType();

Fetches the logged-in user type (requester/technician). Note that this function does not fetch roles.

Returns:
String – Returns user type as a string.

Syntax:
  1. var userType = SDP.getCurrentUserType();
 
Sample Response:
  1. "Technician"
 

SDP.getCurrentUserName();

Fetches the logged-in user name.

Returns:
String – Returns user name as a string.

Syntax:
  1. var userName = SDP.getCurrentUserName();
 
Sample Response:
  1. "John Doe"
 

SDP.getCurrentUserEmail();

Description: Fetches the email address of the current user.

Returns:
String – Returns user email as a string.

Syntax:
  1. var userEmail = SDP.getCurrentUserEmail();
 
Sample Response:
  1. "johndoe@somecompany.com"
 

SDP.getWidgetInfo();

Description: Fetches the current widget info.

Returns:
Object – Returns the widget info object.

Syntax:
  1. var widgetInfo = SDP.getWidgetInfo();
 
Sample Response:
  1. {
  2.     "id": "120747000002587069",
  3.     "name": "Custom Widget",
  4.     "description": "",
  5.     "custom_widget": {
  6.         "id": "120747000002587067"
  7.     }
  8. }
 

SDP.getWidgetMeta();

Description: Fetches the widget meta passed to the widget.

Returns:
Object – Returns the widget meta object.

Syntax:
  1. var widgetMeta = SDP.getWidgetMeta();
 
Sample Response:
  1. {
  2.     "module": "header",
  3.     "instance": {
  4.         "appid": "709641411",
  5.         "appname": "widgetdev",
  6.         "appdisplayname": "Widget Development"
  7.     },
  8.     "personalization": {
  9.         "time_zone": "Asia/Kolkata",
  10.         "time_format": "MMM d, yyyy hh:mm a",
  11.         "date_format": "MMM d, yyyy"
  12.     },
  13.     "userLanguage": "en",
  14.     "userLocale": "en_US",
  15.     "userType": "Technician",
  16.     "userId": "120747000000232217",
  17.     "userName": "Widget Development",
  18.     "userEmail": "widget_dev@sdpdev.onmicrosoft.com",
  19.     "isSDAdmin": true,
  20.     "widget": {
  21.         "id": "120747000002587069",
  22.         "name": "Custom Widget",
  23.         "description": "",
  24.         "custom_widget": {
  25.             "id": "120747000002587067"
  26.         }
  27.     }
  28. }
 

SDP.getWidgetInvokedLocation()

Fetches the location of the current widget.

Returns:
String – Returns the widget location.

Syntax:
  1. var location = SDP.getWidgetInvokedLocation();
 
Sample Response:
  1. “webtab”
 

SDP.getDataPassedByparent();

Fetches the data passed from the parent widget to the child widget by the user when the child widget is opened as a pop-up. The data fetched will be passed only after the SDP.openWidget(); is called.

Returns:
Object – Returns the data object passed by parent widget.

Syntax:
  1. var data = SDP.getDataPassedByparent();

Sample:
  1. {
  2. mode: "new_user"
  3. }
 

SDP.getParentLocation() ;

Fetches the location of the parent widget that has called the child widget.

Returns:
String – Returns the parent widget location.

Syntax:
  1. var parentLocation = SDP.getParentLocation();
 
Sample Response:
  1. “webtab”
 

SDP.getParentWidgetInfo() ;

Fetches the details of the parent widget which has called the child widget.

Returns:
Object – Returns the parent widget info object.

Syntax:
  1. var parentInfo = SDP.getParentWidgetInfo();
 
Sample Response:
  1. {
  2. "id":"100000000000032273",
  3. "name":"Sample Widget",
  4. "description":"Sample Widget",
  5. "custom_widget":{
  6. "id":"100000000000032271"
  7. }
  8. }

    • Related Articles

    • Custom Widget Specifications

      The package directory of your custom widget includes a plugin-manifest.json file. This file contains the configuration details of your custom widget. While some keys included in this file are optional, others are mandatory. Use the following pointers ...
    • Manage Variables/Connection in Custom Widget

      SDP.getVariables() Fetches all the variables associated with the custom widget. Returns: Promise - Resolved with Success or Rejected with Failure. Syntax: SDP.getVariables().then(function(response) { console.log(response); }).catch(function(response) ...
    • Add Custom Widget

      Add Custom Widget to ServiceDesk Plus MSP Cloud Role Required: SDAdmin Go to Setup > Developer Space > Custom Widgets and click New Custom Widget. Follow the steps mentioned below to configure your own custom widget. Provide a name and description to ...
    • Develop Custom Widget Package

      Command Line Interface (CLI) is used to create and package custom widgets. ZET command is the CLI used to package custom widgets for ServiceDesk Plus MSP Cloud. Pre-requisites: In order to create your own custom widgets for ServiceDesk Plus MSP ...
    • Custom Menu

      Custom functions can be executed using Custom Menu to perform a variety of user-defined actions within ServiceDesk Plus MSP Cloud and external applications. You can configure custom functions for custom menu actions in requests, problems, changes, ...