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. }