简单地说,就是通过集成,在ServiceDesk Plus的请求明细页面中,添加自定义动作菜单。通过该动作菜单,技术员可以对集成的第三方应用,执行相应的操作,从而达到与第三方应用互动的目的。 比如:在活动目录中创建用户的请求,技术员在处理这种请求时,通常需要登录到活动目录的域控制器中,执行相应的操作,才能完成该请求。通过外部动作,可以在请求的动作菜单中,添加一个创建账户的菜单项,技术员只要点击该菜单,即可在域控制器中添加用户。这样,可以极大地方便技术员处理这类请求,提高生产效率。
要将ServiceDesk Plus 与第三方应用进行集成,必须修改文件 Request_ActionMenu.xml (它位于: [SDP Home]/server/default/conf )来满足您的要求。
注意 |
1. 您可以在请求明细页面的动作菜单中,点击所添加的动作来访问集成的第三方应用。 2. 动作菜单可以根据需要,加以定制 |
将SDP与第三方应用集成用的基本代码示例:
<menus>
<menu name="Add Jira Ticket" refresh="true">
<displaytext>Create a JIRA ticket</displaytext>
<roles>
<role>SDAdmin</role>
</roles>
<template>
<template>Default Request</template>
</templates>
<invoke>
<class>com.manageengine.servicedesk.actionplugin.sample.JIRAIntegration</class>
</invoke>
</menu>
</menus>
上述示例,通过'Add Jira Ticket'菜单,将问题追踪软件(JIRA)与SDP进行集成。它在SDP的请求动作菜单中,添加了一项'Add Jira Ticket',点击该菜单式,它调用类: com.manageengine.servicedesk.actionplugin.sample.JIRAIntegration 执行具体的操作。
注意 |
1. 上述示例中,类JIRAIntegration默认ServiceDesk Plus已经提供。调用它可执行集成动作。 2.因为涉及处理请求,所以必须指定访问它的角色,以及要使用的请求模板,它们分别在<roles> 和 <template> 标签中加以定义。 |
下表详细解释集成配置代码中不同的标签及其作用:
标签 |
描述 |
示例 |
|
包含在地址菜单下创建的所有菜单项,它是根节点 |
<menus></menus> |
|
在动作菜单中创建单个的菜单。每个菜单的名称必须是唯一的。 |
<menu>JIRA Integration</menu> <menu>SDP Integration</menu> |
|
配置在用户界面中显示的菜单内容,支持国际化(如:使用 "sdp.action.createticket") ,但是必须确保相应的Key添加到对应的Properties文件中(位于 'custom/i18n/*) |
<displaytext>SCP to Jira Integration</displaytext> <displaytext>SCP to SDP Integration</displaytext> |
|
包含所有角色 (访问权限) ,以便在动作菜单中访问/查看相应的菜单。 |
<roles></roles> |
|
定义可以访问该外部动作菜单的角色 |
<role>SDADMIN</role> <role>SDGUEST</role> |
|
参照请求所关联的请求模板。如果不指定,则默认所有模板都将被考虑。 |
<templates></templates> |
|
指定请求关联的模板 |
<template>default template</template> <template>system defined template</template> |
|
定义该外部动作所要执行的具体动作(调用类) |
<invoke></invoke> |
|
指定具体的被调用类的全路径名称 |
<class>JiraActionImplementation</class> |
要定制SDP的动作菜单,使它能在第三方应用中执行相关的请求操作,需要在被调用的Java类中,扩展DefaultActionInterface 。
注意 |
1. DefaultActionInterface 为标准接口,运行您扩展要执行的动作。 2. 该 ActionInterface 实现类应该在相应的 .xml文件中指定。 |
扩展 DefaultActionInterface:
package com.manageengine.servicedesk.actionplugin.sample; import com.manageengine.servicedesk.actionplugin.executor.ActionInterface import com.manageengine.servicedesk.actionplugin.executor.ExecutorData public class JIRAIntegration extends DefaultActionInterface { public JSONObject execute(ExecutorData executorData) throws Exception { } }
|
在ExecutorData 中可用的方法:
Package: com.manageengine.servicedesk.actionplugin.executor.ExecutorData
a. getActionMenuData( )
参数 |
返回值 |
动作 |
|
String |
gets the name of the action menu |
|
String |
gets the display name for the action menu |
|
String |
gets the configured implementation class |
|
Boolean |
gets info related to whether the page should be refreshed or not) |
|
Array |
gets info about list of allowed roles; is empty when not configured |
|
Array |
gets info about list of allowed templates; remains empty when not configured |
b.getDataJSON( )
将返回调用该菜单的请求的JSON对象。示例数据如下: { "WORKORDERID":"4", "REQUESTER":"Guest", "CREATEDBY":"administrator", "DUEBYTIME":"-1", "RESPONSEDUEBYTIME":"-1", "CREATEDBY":"administrator", "FR_DUETIME":"-1", "RESPONDEDTIME":"0", "RESOLVEDTIME":"0", "COMPLETEDTIME":"0", "SHORTDESCRIPTION":"The printer is not working from the machines that are in the 10th floort", "TIMESPENTONREQ":"0hrs 0min", "SUBJECT":"Printer not working", "REQUESTTEMPLATE":"Default Request", "MODE":" ", "SLA":" ", "ASSET":" ", "DEPARTMENT":" ", "SITE":" ", "CATEGORY":" ", "SUBCATEGORY":" ", "ITEM":" ", "TECHNICIAN":" ", STATUS":"Open", "PRIORITY":" ", "LEVEL":" ", "IMPACT":" ", "URGENCY":" ", "IMPACTDETAILS":" ", "REQUESTYPE":" ", "CLOSURECODE":" ", "CLOSURECOMMENTS":" ", "GROUP":" ", }
|
用户可以通过编程,实现自己想要的操作。
现在,有两种方式更新请求:一是使用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" }], }
|
b. 更新请求
{ "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的缺省实现方法,如果客户有特殊要求,需要另外定义一个其它的 xml ,并实现特殊的JIRA。
<?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://seshadri-0040: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>
|