Home / Objective and Use Cases of HTML Invocation

Objective and Use Cases of HTML Invocation


Objective  : The main objective is to invoke a custom HTML File from Request Custom Menu's

Why is it needed : Currently we support an integration with JIRA/ Other Third party using Script/Class file. Using HTML File Invocation, It is possible to invoke a Custom HTML file. It is just another way of integrating the Third party applications using the User Interface. 

Examples :
  • Before submitting the ticket to JIRA, Technician can modify the Ticket Properties from the User Interface and then submit the ticket
  • Before creating an User in ADMP, Technician can modify the User properties from the User Interface and then create user in AD.
How to Use :

In Request Custom Menus, We can have Custom HTML files as per the requirement and the files has to be placed under SDP_HOME\integration\resources folder. All the other dependencies(Javascript and CSS) should be placed under resources folder.
 
Once the Menu is invoked from the request details page, configured HTML file will be loaded in a new window with request object as global javascript variable "sdpJson
  • Request details is accessible inside pop up window using JavaScript as sdpJson[field_name].
  • Menu Id of the invoked menu can be accessed as MENUID
  • Request details can be accessed as sdpJson['PRIORITY'] for priority value and sdpJson['WORKORDERID'] for request ID as shown in image.

           

To make server request from custom web page to be handled by your Class implementation or Script implementation use below parameters than only request will be passed to your Class/Script
    • URL         :   "/servlet/ActionExecutorServlet"
    • METHOD  :   "POST"
    • DATA       :   JSON data in format show below, only below format is accepted. This whole JSON object will be passed to your custom Class/Script.

               

Using Classes :
  • Create a Java file that will handle your request.
  • The Java file should extend the DefaultActionInterface as explained below.

import com.manageengine.servicedesk.actionplugin.executor.ActionInterface;
import com.manageengine.servicedesk.actionplugin.executor.ExecutorData;

public class IntegrationClassName extends DefaultActionInterface
{
    public JSONObject execute ( ExecutorData executorData ) throws Exception
    {
         //your code here
    }
}
  • ExecutorData Object is a parameter to execute method which contains following methods to access http request data sent from custom webpage and additional properties such as details of menu which is invoked.
    • getAdditionalProperties()  : Returns HashMap of menu details which is invoked.
    • getHtmlDataJson()             : Returns JSONObject passed as data parameter using http request from custom webpage
    • getDataJSON()                             : Returns JSONObject passed  as props parameter using http request from custom webpage
    1. //Accessing additional properties
    2. HashMap menuMap = executorData.getAdditionalProps();
    3. String menuName = (String)menuMap.get("MENUNAME");// name of menu invoked
    4. //Accessing http request data
    5. JSONObject dataJson=data.getHtmlDataJson(); // JSON data passed here

  • execute function should return JSONObject which will be passed as response.
  • To compile java file use jdk v1.6 and add AdventNetServiceDeskCommon.jar (you can find it inside [SDP_HOME]/ directory) file to class path.
  • Add created class/jar file to [SDP_Home]/integration/lib/ directory.
  • Add configurations files to [SDP_Home]/integration/conf/ directory (If Any).
Note : It is recommended to add configurations such as url, username, password, mappings etc to some xml or json file and than read that file from java file instead hard coding it in java file.

Using Scripts:
  • Custom Scripts should present under [SDP_Home]/integration/custom_scripts/ directory 
  • Supported arguments for Custom Script

$COMPLETE_JSON_FILE ---> Complete Request Object will be saved to a JSON file and the file path will be passed as String Object. For Ex : (SDP_Home\integration\custom_scripts\request\12_1426143538036.json).

$HTML_DATA_JSON_FILE --> HTTP request "data" parameter will be saved to a JSON file along with Menu Name and XML File Path. JSON file path will be passed as String Object. For Ex : (SDP_Home\integration\custom_scripts\request\12_1426143538036.json).









     RSS of this page