XOps支持XOps事件与外部服务管理平台之间的双向同步。 此集成有助于将调查活动保持在跨平台的一致性,因此在一个平台中的更新将反映在另一个平台中。
欲了解更多信息,请参见创建与服务管理平台的双向集成。
要配置ServiceNow集成,请完成以下五个步骤。
服务API密钥启用与外部工具和服务的可扩展集成,格式如下:R=<...>|K=<...>。 欲了解有关如何创建服务API密钥的更多信息,请参见为Cato API生成API密钥。
创建服务API密钥后,将其复制并保存,以便可输入到ServiceNow平台。
创建一个REST消息以发送ServiceNow事件的详细信息到Cato:
创建一个触发REST消息的业务规则。
要创建业务规则:
- 在您的ServiceNow平台中,导航到 全部 > 系统定义 > 业务规则。
- 点击 新建。
-
在 业务规则新记录 表单中,添加以下详细信息:
- 名称:为业务规则添加一个名称
- 表:事件
- 时间:之后
- 更新:为真(选中复选框)
- 过滤条件:备注变更
-
在 高级 标签上,添加此脚本:
(function executeRule(current, previous) { try { var lastComment = current.comments.getJournalEntry(1) || ''; lastComment = stripJournalHeader(lastComment); if (!lastComment) { gs.info("GraphQL webhook: Empty comment, skipping " + current.number); return; } var accountId = current.u_cma_account_id; var storyId = current.u_cma_story_id; gs.info("GraphQL webhook: accountId " + accountId + " story " + storyId); if (!accountId || !storyId) { gs.error("GraphQL webhook: Missing accountId/storyId for " + current.number); return; } var gqlQuery = "mutation CreateStoryComment($accountId: ID!, $input: AddStoryCommentInput!) {" + " xdr(accountId: $accountId) {" + " addStoryComment(input: $input) {" + " comment { id type __typename }" + " __typename" + " }" + " __typename" + " }" + "}"; var body = { query: gqlQuery, variables: { accountId: accountId.toString(), input: { type: "USER", storyId: storyId.toString(), text: lastComment } } }; var apiKey = gs.getProperty('cma_prod_api_key'); var r = new sn_ws.RESTMessageV2('Update XDR story comments CMA Prod', 'post'); r.setRequestHeader('Content-Type', 'application/json'); r.setRequestHeader('Accept', 'application/json'); r.setRequestHeader('x-api-key', apiKey); r.setRequestBody(JSON.stringify(body)); //var response = r.execute(); // can be changed to Async - only for debug purposes var eccSysId = r.executeAsync(); gs.info("GraphQL webhook queued, ECC sys_id=" + eccSysId); var status = response.getStatusCode(); var responseBody = response.getBody(); // Safe logging (see next section for masking) gs.info("GraphQL webhook: status=" + status); gs.info("GraphQL webhook: responseBody=" + responseBody); } catch (ex) { gs.info("GraphQL webhook: Failed: " + ex.message); } function stripJournalHeader(text) { text = text || ''; if (text.indexOf('\n') > -1) { return text.split('\n').slice(1).join('\n').trim(); } return text.trim(); } })(current, previous); - 点击 提交。
0 条评论
请登录写评论。