ServiceDesk Plus

    SAMPLE CLASS FILE FOR ADDING APPROVERS THROUGH CUSTOM TRIGGER

     

    package com.servicedeskplus.integration;

    import org.json.*;

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

    public class ServiceApproval extends DefaultActionInterface {
    public JSONObject execute(ExecutorData executorData) throws Exception
    {
    JSONObject requestData = executorData.getDataJSON();

    JSONObject resultjson = new JSONObject();
    JSONObject operationJson = new JSONObject();
    JSONArray approvalArray,approvalArray1;
    JSONObject approvalObject,approvalObject1;
    String name = requestData.getString("REQUESTER");
    JSONArray inputObject = new JSONArray();
    if (name.contains("Howard"))
    {
    approvalArray = new JSONArray();
    approvalObject = new JSONObject();
    approvalArray.put( "heather.graham@xyz.com");
    approvalObject.put("StageOne", approvalArray);

    approvalArray1 = new JSONArray();
    approvalObject1 = new JSONObject();
    approvalArray1.put("heather.graham123@xyz.com");
    approvalObject1.put("StageTwo", approvalArray1);
    inputObject.put(approvalObject);
    inputObject.put(approvalObject1);
    operationJson.put("INPUT_DATA", inputObject);
    }
    else if (name.contains("Jeniffer"))
    {
    approvalArray = new JSONArray();
    approvalObject = new JSONObject();
    approvalArray.put( "heather.graham@xyz.com");
    approvalObject.put("StageOne", approvalArray);

    approvalArray1 = new JSONArray();
    approvalObject1 = new JSONObject();
    approvalArray1.put("heather.graham123@xyz.com");
    approvalObject1.put("StageTwo", approvalArray1);
    inputObject.put(approvalObject);
    inputObject.put(approvalObject1);
    operationJson.put("INPUT_DATA", inputObject);
    }
    operationJson.put("OPERATIONNAME", "ADD_APPROVAL_STAGE");
    resultjson.append("operation", operationJson);
    String message = "Sample class file for adding approvers";
    resultjson.put("message", message);
    resultjson.put("result", "success");
    return resultjson;
    }
    }

     

    Copyright © 2017, ZOHO Corp. All Rights Reserved.