本文档为开发人员创建插件和建立 ServiceDesk Plus 与其他各种第三方应用程序之间的集成提供了程序信息。
完整的请求工作流程要求支持团队执行不同的任务。有时,支持团队可能会通过访问相关应用程序来完成某些任务,这可能会超出应用程序的限制。
因此,为了克服引入第三方应用程序执行任务(如问题跟踪器集成、活动目录账户创建和新邮件账户创建)的繁琐过程,您可以利用 ServiceDesk Plus 中的外部动作插件选项。只需单击动作菜单,该选项就能帮助支持团队在请求页面上执行各种与第三方相关的动作。
场景: 比如在一个使用 ServiceDesk Plus 作为客户支持和 JIRA 作为错误跟踪的组织。这就是外部动作插件框架发挥作用的地方,他们可以利用该框架在 ServiceDesk Plus 和 JIRA 之间建立集成。因此,他们可以从 “请求 ”页面的 “动作”菜单中创建 JIRA 问题。 |
开发外部动作插件所需技能
开发插件需要具备以下方面的知识:
该插件设计有一个实施类,可通过菜单调用。 菜单可在 ServiceDesk Plus 的 "管理 "模块下进行配置。
实施类
配置菜单
Java 类应扩展 “DefaultActionInterface”,并通过 “execute ”方法提供实现。所需的导入类可在“[SCP_HOME]\applications\extracted\AdventNetSupportCenter.eear\AdventNetHelpDesk.ear\” 下的 “AdventNetHelpDesk.jar ”和 “AdventNetServiceDeskCommon.jar ”中找到。
package com.manageengine.servicedesk.actionplugin.sample; import com.manageengine.servicedesk.actionplugin.executor.ActionInterface import com.manageengine.servicedesk.actionplugin.executor.ExecutorData public class SampleActionImplementation extends DefaultActionInterface { public JSONObject execute(ExecutorData executorData) throws Exception { ExecutorData data = executorData;
ActionMenuData menuData = data.getActionMenuData(); String menuName = (String) menuData.getMenuName(); JSONObject scpValuesObj = data.getDataJSON();
//You can have your implementation here
} } |
执行方法
执行方式将在执行方法中定义,参数为 ExecutorData 对象:
方法:执行(ExecutorData)
返回: JSONObject
执行数据:
ExecutorData 对象是 Execute 方法的参数。 利用它,我们可以通过 getActionMenuData() 方法获取调用菜单的详细信息。 该方法会返回一个名为 ActionMenuData 的对象:
i) ActionMenuData - 提供了调用操作的菜单信息。
以下是可用于提取值的方法及其各自的数据类型:
参数
返回值
getMenuName
返回调用的操作菜单名称。
String
getDisplayText
返回调用菜单的显示名称。
String
getExecutorClass
返回为该菜单指定的 Java 执行类的名称。
String
getAllowedRoles
返回允许使用此菜单的角色列表。
ArrayList
getAllowedTemplates
返回该菜单可用的模板列表。
ArrayList
ii) JSON 数据- 调用 ExecutorData 中的 getDataJSON 方法可以获取触发菜单的请求的详细信息。 该方法将以 JSON 对象的形式返回详细信息:
{
"WORKORDERID": "1","REQUESTER": "Guest","CREATEDBY": "administrator","CREATEDTIME": "1469685688321","DUEBYTIME": "1469692888321","RESPONSEDUEBYTIME": "-1","FR_DUETIME": "-1","RESPONDEDTIME": "0","RESOLVEDTIME": "0","COMPLETEDTIME": "0","SHORTDESCRIPTION": "","TIMESPENTONREQ": "0hrs 0min","SUBJECT": "Testing for Bulk SMS","REQUESTTEMPLATE": "Default Request","MODE": "E-Mail","SLA": "Medium SLA","ASSET": "","DEPARTMENT": " HR Department","EDITORID": "null","EDITING_STATUS": "0","IS_CATALOG_TEMPLATE": "false","SITE": "Singapore Support","ISVIPUSER": "No","SERVICE": "","CATEGORY": "Software","SUBCATEGORY": "MS Office","ITEM": "Install","TECHNICIAN": "Heather Graham","TECHNICIAN_LOGINNAME": "Heather","STATUS": "Open","PRIORITY": "Medium","LEVEL": "Tier 2","IMPACT": "","URGENCY": "High","IMPACTDETAILS": "-","REQUESTTYPE": "Incident","APPROVAL_STATUS": "","CLOSURECODE": "","CLOSURECOMMENTS": "","FCR": "false","YETTOREPLYCOUNT": "","GROUP": "Hardware Problems","DESCRIPTION": "","Test": ""}
--------------------------------------------------------------------------------------------------------------------
有了这些信息,客户就可以编写自己的执行代码来执行必要的操作。现在,有两种方法可以更新工单。第一种方法是使用 SDP 提供的 REST API 支持,更新请求或执行添加工作日志、注释、决议等操作;第二种方法是使用动作插件框架支持的默认返回功能。
执行方法会返回一个 JSON 对象。默认情况下,如果返回的 JSON 符合支持的格式,则支持添加注释和更新请求。
a. 为请求添加注释
{ "message":"Request Added Successfully", "result":"success", "operation":[ { "INPUT_DATA": [ { "notes": { "notestext":"Tickethas been created in JIRA and information populated in SDP" } }], "OPERATIONNAME":"ADD_NOTE" }], }
|
{ "message":"Request Added Successfully", "result":"success", "operation":[ { "INPUT_DATA": [ { "Jira ID":"35", "Jira Key":"SDP-3", "self":"http://jira-server/rest/api/2/issue/35" }], "OPERATIONNAME":"UPDATE_REQUEST" }], }
|
用于配置请求动作菜单
<?xml version="1.0" encoding="UTF-8"?>
<menus>
<menu name=""JiraIntegration"" refresh="true">
<displaytext>SCP to Jira Integration</displaytext>
<roles>
<role>ModifyRequests</role>
</roles>
<template>
<template>System Defined Template</template>
</templates>
<invoke>
<class>com.manageengine.supportcenter.integrations.jira.action.JiraActionImplementation</class>
</invoke>
</menu>
<menu name=""SDP Integration"" refresh="true">
<displaytext>SCP to SDP Integration</displaytext>
<roles>
<role>ModifyRequests</role>
</roles>
<templates>
<template>System Defined Template</template>
<template>testing</template>
</templates>
<invoke>
<class>com.manageengine.supportcenter.integrations.jira.action.SDPActionImplementation</class>
</invoke>
</menu>
</menus>
对于JIRA 集成
注:我们将为 JIRA 提供默认实施。 为此,客户需要定义另一个包含 JIRA 特定实现的 xml。
<?xml version="1.0" encoding="UTF-8"?> <menus> <!-- The menu name should match the one specified in the ActionMenu xml --> <menu name="JiraIntegration"> <--Specifies the input parameters that should be passed to JIRA--> <request> <!-- Credentials need to login to JIRA --> <username>administrator</username> <password>administrator</password> <!-- URL to invoke to perform the operation --> <url>http://localhost:8080/rest/api/2/issue/</url> <!-- Params to be passed to the URL --> <param> <name>project</name> <type>projectpicker</type> <value>SCP</value> </param> <param> <name>Issuetype</name> <type>select</type> <value>Bug</value> <!-- Dynamic parameters can be specified by a $ prefix. In this case, the value for the variable will be taken from SDP and passed. -->
</param> <param> <name>summary</name> <type>textfield</type> <value>$subject</value> <param> <name>priority</name> <type>select</type> <value>$priority</value> </param> <param> <name>description</name> <type>textarea</type> <value>$description</value> </param> <param> <name>labels</name> <type>labels</type> <value>$JIRA_ISSUE_ID</value> </param> <param> <name>environment</name> <type>textarea</type> <value>$description</value> </param> <param> <name>duedate</name> <type>datepicker</type> <value>$dueByTime</value> </param> <param> <name>customfield_10002</name> <type>url</type> <value>$Company Website</value> </param> <param> <name>customfield_10100</name> <type>url</type> <value>$JIRA_SelectList</value> </param> <param> <name>customfield_10200</name> <type>float</type> <value>$Jira Numeric Field</value> <param> <name>customfield_10300</name> <type>textfield</type> <value>$Jira_Text Field</value> </param> <param> <name>customfield_10301</name> <type>datetime</type> <value>$Jira_Date Time</value> </param> <param> <name>customfield_10302</name> <type>datepicker</type> <value>$Jira_Date Picker</value> </param> <param> <name>customfield_10303</name> <type>userpicker</type> <value>$Jira_User Picker</value> </param> <param> <name>customfield_10304</name> <type>grouppicker</type> <value>$Jira_Group Picker</value> <param> <name>customfield_10306</name> <type>textarea</type> <value>$Jira_Free Text Field</value> </param> </request> <success>Successfully Integrated with Jira and the Jira id is : $id</success> <failure>Failed to Integrate to jira</failure> <!-- Specifies the fields that are to be updated after the action is executed --> <response> <param> <!-- name indicates the attribute in the return JSON object received from JIRA API --> <name>JIRA_ISSUE_ID</name> <!-- value indicates the SDP field that should be updated with the JIRA value --> <value>$ id</value> </param> <param> <!-- name indicates the attribute in the return JSON object received from JIRA API --> <name>JIRA_ISSUE_URL</name> <!-- value indicates the SDP field that should be updated with the JIRA value --> <value>$ self</value> </param> <!-- In any note needs to be added at the end of the operation, then it needs to be specified here. $message will take the value from the json object returned by JIRA. Hardcoded messages can also be given --> <notes> <note>Ticket is created in jira with key : $key And with Id: $id</note> <note>Ticket is created in jira with issueID : $id</note> </notes> </response> </menu> <menus>
|