flashduty-knowledge-base 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iife/en.js CHANGED
@@ -1370,7 +1370,7 @@ Alibaba Cloud Monitor event alert to Flashduty severity level mapping:
1370
1370
  | WARNING | Warning | Warning |
1371
1371
  | INFO | Info | Info |
1372
1372
 
1373
- </div>`,h=`---
1373
+ </div>`,u=`---
1374
1374
  title: "Alibaba Cloud Monitor CM Metrics Integration"
1375
1375
  description: "Sync Alibaba Cloud Monitor alert events to Flashduty via webhook for automated alert noise reduction"
1376
1376
  date: "2025-05-19T10:00:00+08:00"
@@ -1595,7 +1595,7 @@ Alibaba Cloud SLS monitoring to Flashduty alert severity mapping:
1595
1595
  | 2 | Info | Info |
1596
1596
 
1597
1597
  </div>
1598
- `,u={CustomAlert:t,Email:a,N9e:i,Prometheus:o,Grafana:s,Zabbix:r,UptimeKuma:l,AliyunARMS:d,AliyunCmEvent:c,AliyunCm:h,AliyunSLS:e,AWSCW:e,AzureMonitor:`---
1598
+ `,h={CustomAlert:t,Email:a,N9e:i,Prometheus:o,Grafana:s,Zabbix:r,UptimeKuma:l,AliyunARMS:d,AliyunCmEvent:c,AliyunCm:u,AliyunSLS:e,AWSCW:e,AzureMonitor:`---
1599
1599
  title: "AWS CloudWatch Integration"
1600
1600
  description: "Sync AWS CloudWatch alert events to Flashduty via webhook to achieve automated alert noise reduction"
1601
1601
  date: "2025-05-19T10:00:00+08:00"
@@ -7806,4 +7806,288 @@ https://cmdb.com/vm?sn=VM123456
7806
7806
  1. When referenced content does not exist, Link integration will still generate the corresponding link but will not be able to retrieve the value
7807
7807
  2. Each channel can bind up to three Link integrations
7808
7808
  3. Pay attention to reference syntax; improper variable reference formatting will result in failure to retrieve corresponding values
7809
- `};n.FlashDocsEn=u})(window);
7809
+ `,ServiceNowSync:`---
7810
+ title: "ServiceNow Sync"
7811
+ description: "Sync incidents with ServiceNow Incidents through ServiceNow sync webhook."
7812
+ date: "2025-05-19T10:00:00+08:00"
7813
+ url: "https://docs.flashcat.cloud/en/flashduty/service-now-sync"
7814
+ ---
7815
+
7816
+ Through ServiceNow sync webhook, Flashduty incidents are associated and synchronized with ServiceNow Incidents to achieve integration between Flashduty and ServiceNow.
7817
+
7818
+ ## In ServiceNow
7819
+
7820
+ ### Create User
7821
+
7822
+ 1. Log in to the ServiceNow instance console, select \`ALL\`, enter \`USERS\` and select \`Organization\`-\`Users\`.
7823
+ 2. Click \`New\` to create a new user.
7824
+ 3. In the edit page, enter \`flashduty\` in the \`User ID\` field.
7825
+ 4. Keep \`Password needs reset\`, \`Web service access only\`, and \`Internal Integration User\` unchecked.
7826
+ 5. Submit and save.
7827
+
7828
+ <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/snow/snow-1.png" />
7829
+
7830
+ ### Configure User
7831
+
7832
+ The user used to access ServiceNow needs to have administrator roles.
7833
+
7834
+ 1. On the user list page, find the newly created \`flashduty\` user and go to the configuration page.
7835
+ 2. In the edit page, click \`Set Password\` to set a password.
7836
+ 3. Click \`Roles\` to add **admin and itil** roles.
7837
+ 4. Click \`Update\` to update the configuration.
7838
+
7839
+ <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/snow/snow-2.png" />
7840
+
7841
+ ## In Flashduty
7842
+
7843
+ ### Configure Integration
7844
+
7845
+ Enter the username/password and instance name configured above into the integration information on the left and click Next to configure.
7846
+
7847
+ - **Integration Name:** Define a name for the current integration.
7848
+ - **Management Team:** When a management team is selected, only team members and tenant administrators can edit this integration.
7849
+ - **Channel:** Select the channel where this integration takes effect.
7850
+ - **Sync Direction:**
7851
+ - To_ServiceNow: Sync Flashduty incidents to ServiceNow.
7852
+ - From_ServiceNow: Sync ServiceNow Incidents to Flashduty.
7853
+ - Two-way: Bidirectional sync between Flashduty and ServiceNow.
7854
+ - **Trigger Mode**:
7855
+ - Auto Trigger: Requires configuration of corresponding conditions, Flashduty will automatically sync incidents that meet the conditions to ServiceNow.
7856
+ - Manual Trigger: Requires manual triggering of ServiceNow sync in the More Actions section of the incident details page (the integration configuration name is the trigger name).
7857
+ - **Severity Mapping:** ServiceNow's Priority is determined by the combined values of Impact and Urgency, so you can refer to ServiceNow's \`Priority Lookup Rules\` for configuration. Additionally, note that only when ServiceNow Incident's Urgency changes will it trigger updates to Flashduty incident severity.
7858
+ - **Custom Field Mapping:** You can choose to sync certain labels or all labels of incidents as well as custom field content to ServiceNow fields (only text-type fields are supported).
7859
+
7860
+ ## In ServiceNow
7861
+
7862
+ When sync direction is set to From_ServiceNow or Two-way, additional configuration is required in ServiceNow to sync ServiceNow Incidents to Flashduty. When syncing to Flashduty, there are two methods available, choose based on your actual needs.
7863
+
7864
+ ### Manual Sync
7865
+
7866
+ This method relies on ServiceNow's UI Action and Script Include configuration. The effect achieved by following the steps below: When creating or updating an Incident, you can see a button to send sync requests in the function area. Triggering this button will sync the current Incident content to Flashduty. Note that if the request fails when triggered, please retry (retry interval should be greater than 10 seconds).
7867
+
7868
+ #### Configure UI Action
7869
+
7870
+ 1. Log in to the ServiceNow instance console, select \`ALL\`, enter \`UI Actions\` and select \`System Definition\`-\`UI Actions\`.
7871
+ 2. Click \`New\` to create a new Action.
7872
+ 3. Enter **Send To Flashduty** in \`Name\`, select **Incident** in \`Table\`.
7873
+ 4. Keep \`Form button\`, \`Active\`, \`Show insert\`, \`Show update\`, \`Client\`, \`List v2/3 Compatible\` checked.
7874
+ 5. Enter **onClick();** in \`Onclick\`.
7875
+ 6. Enter the following in \`Script\`:
7876
+
7877
+ \`\`\`js
7878
+ function onClick() {
7879
+ g_form.save();
7880
+
7881
+ var ga = new GlideAjax("IncidentWebhookHelperAjax");
7882
+ ga.addParam("sysparm_name", "sendWebhook");
7883
+ ga.addParam("sysparm_sys_id", g_form.getUniqueValue());
7884
+
7885
+ ga.getXMLAnswer(function (response) {
7886
+ alert("Webhook Triggered: " + response);
7887
+ });
7888
+ }
7889
+ \`\`\`
7890
+
7891
+ 7. Submit and save.
7892
+
7893
+ #### Configure Script Include
7894
+
7895
+ 1. Log in to the ServiceNow instance console, select \`ALL\`, enter \`Script Includes\` and select \`System Definition\`-\`Script Includes\`.
7896
+ 2. Click \`New\` to create a new Script Include.
7897
+ 3. Enter **IncidentWebhookHelper** in \`Name\`, select **All application scopes** in \`Accessible from\`.
7898
+ 4. Keep \`Client callable\` and \`Active\` checked.
7899
+ 5. Enter the following content in \`Script\`, where you need to add the integration push URL in **request.setEndpoint**:
7900
+
7901
+ <div class="hide">
7902
+
7903
+ Note: The body configures default receiving fields. If you have custom fields that need to be synced to Flashduty, you need to manually add content to the body. For example, if you want to add a field named: test_001 (this field name can be obtained when adding custom fields in the integration configuration, do not use the field name displayed in the ServiceNow Incident form), then you need to add to the body: test_001: current.getDisplayValue("test_001").
7904
+
7905
+ </div>
7906
+
7907
+ \`\`\`js
7908
+ var IncidentWebhookHelper = Class.create();
7909
+ IncidentWebhookHelper.prototype = {
7910
+ initialize: function () {},
7911
+
7912
+ sendIncidentWebhook: function (current) {
7913
+ function getLastComment(sysId) {
7914
+ var journalGR = new GlideRecord("sys_journal_field");
7915
+ journalGR.addQuery("element_id", sysId);
7916
+ journalGR.addQuery("element", "comments");
7917
+ journalGR.orderByDesc("sys_created_on");
7918
+ journalGR.setLimit(1);
7919
+ journalGR.query();
7920
+ if (journalGR.next()) {
7921
+ return journalGR.getValue("value");
7922
+ }
7923
+ return "";
7924
+ }
7925
+
7926
+ var body = {
7927
+ action_type: current.isNewRecord() ? "insert" : "update",
7928
+ number: current.getValue("number"),
7929
+ sys_id: current.getUniqueValue(),
7930
+ short_description: current.getValue("short_description"),
7931
+ description: current.getValue("description"),
7932
+ state: current.getDisplayValue("state"),
7933
+ impact: current.getDisplayValue("impact"),
7934
+ urgency: current.getDisplayValue("urgency"),
7935
+ comments: getLastComment(current.getUniqueValue()),
7936
+ <label name='field_mapping' tab='6'>{original.key}: current.getDisplayValue("{original.key}")</label>
7937
+ };
7938
+
7939
+ try {
7940
+ var request = new sn_ws.RESTMessageV2();
7941
+ request.setHttpMethod("POST");
7942
+ request.setEndpoint("PUSH URL");
7943
+ request.setRequestHeader("Content-Type", "application/json");
7944
+ request.setRequestBody(JSON.stringify(body));
7945
+ request.executeAsync();
7946
+ } catch (ex) {
7947
+ gs.error("Webhook Call failed: " + ex.message);
7948
+ }
7949
+ },
7950
+
7951
+ type: "IncidentWebhookHelper",
7952
+ };
7953
+ \`\`\`
7954
+
7955
+ 6. Submit and save.
7956
+ 7. Return to the Script Includes list and continue creating.
7957
+ 8. Click \`New\` to create a new Script Include.
7958
+ 9. Enter **IncidentWebhookHelperAjax** in \`Name\`, select **All application scopes** in \`Accessible from\`.
7959
+ 10. Keep \`Client callable\` and \`Active\` checked.
7960
+ 11. Enter the following content in \`Script\`:
7961
+
7962
+ \`\`\`js
7963
+ var IncidentWebhookHelperAjax = Class.create();
7964
+ IncidentWebhookHelperAjax.prototype = Object.extendsObject(
7965
+ global.AbstractAjaxProcessor,
7966
+ {
7967
+ sendWebhook: function () {
7968
+ var sysId = this.getParameter("sysparm_sys_id");
7969
+ var gr = new GlideRecord("incident");
7970
+ if (gr.get(sysId)) {
7971
+ var helper = new IncidentWebhookHelper();
7972
+ helper.sendIncidentWebhook(gr);
7973
+ return "Success";
7974
+ }
7975
+ return "Request failed";
7976
+ },
7977
+ }
7978
+ );
7979
+ \`\`\`
7980
+
7981
+ 12. Submit and save.
7982
+
7983
+ ### Auto Sync
7984
+
7985
+ This method relies on ServiceNow's Business Rules configuration. Using this method, you can automatically sync Incidents to Flashduty when there are new or update events.
7986
+
7987
+ #### Configure Business Rules
7988
+
7989
+ 1. Log in to the ServiceNow instance console, select \`ALL\`, enter \`Business Rules\` and select \`System Definition\`-\`Business Rules\`.
7990
+ 2. Click \`New\` to create a new Business Rule.
7991
+ 3. Enter **Send To Flashduty** in \`Name\`, select **Incident** in \`Table\`.
7992
+ 4. Keep \`Advanced\` and \`Active\` checked.
7993
+ 5. In the \`When to run\` section, select **async** in \`When\`, keep \`Insert\` and \`Upsert\` checked, configure others as needed.
7994
+ 6. In the \`Advanced\` section, enter the following content in \`Script\`, where you need to add the integration push URL in **endpoint**:
7995
+
7996
+ <div class="hide">
7997
+
7998
+ Note: The body configures default receiving fields. If you have custom fields that need to be synced to Flashduty, you need to manually add content to the body. For example, if you want to add a field named: test_001 (this field name can be obtained when adding custom fields in the integration configuration, do not use the field name displayed in the ServiceNow Incident form), then you need to add to the body: test_001: current.getDisplayValue("test_001").
7999
+
8000
+ </div>
8001
+
8002
+ \`\`\`js
8003
+ (function executeRule(current, previous) {
8004
+ function getLastComment(recordSysId) {
8005
+ var journalGR = new GlideRecord("sys_journal_field");
8006
+ journalGR.addQuery("element_id", recordSysId);
8007
+ journalGR.addQuery("element", "comments");
8008
+ journalGR.orderByDesc("sys_created_on");
8009
+ journalGR.setLimit(1);
8010
+ journalGR.query();
8011
+ if (journalGR.next()) {
8012
+ var comment = journalGR.getValue("value");
8013
+ return comment;
8014
+ }
8015
+
8016
+ return "";
8017
+ }
8018
+
8019
+ var operation = current.operation() || "unknown";
8020
+ var isPreviousNull = previous === null;
8021
+ var createdOn = current.getValue("sys_created_on");
8022
+ var updatedOn = current.getValue("sys_updated_on");
8023
+ var isNewRecord = createdOn === updatedOn;
8024
+
8025
+ var action = "update";
8026
+ if (isPreviousNull && isNewRecord) {
8027
+ action = "insert";
8028
+ }
8029
+
8030
+ var body = {
8031
+ action_type: action,
8032
+ number: current.getValue("number"),
8033
+ sys_id: current.getUniqueValue(),
8034
+ short_description: current.getValue("short_description"),
8035
+ description: current.getValue("description"),
8036
+ state: current.getDisplayValue("state"),
8037
+ impact: current.getDisplayValue("impact"),
8038
+ urgency: current.getDisplayValue("urgency"),
8039
+ comments: getLastComment(current.getUniqueValue()),
8040
+ <label name='field_mapping' tab='4'>{original.key}: current.getDisplayValue("{original.key}")</label>
8041
+
8042
+ };
8043
+
8044
+ try {
8045
+ var endpoint = "";
8046
+ var request = new sn_ws.RESTMessageV2();
8047
+ request.setHttpMethod("POST");
8048
+ request.setEndpoint(endpoint);
8049
+ request.setRequestHeader("Content-Type", "application/json");
8050
+ request.setRequestBody(JSON.stringify(body));
8051
+ request.executeAsync();
8052
+ } catch (ex) {
8053
+ gs.error("Error sending webhook: " + ex.message);
8054
+ }
8055
+ })(current, previous);
8056
+ \`\`\`
8057
+
8058
+ 7. Submit and save.
8059
+
8060
+ ## Sync Information
8061
+
8062
+ ### Form Fields
8063
+
8064
+ | ServiceNow | Flashduty | Notes |
8065
+ | ------------------- | ------------- | ----- |
8066
+ | Short_description | Title | |
8067
+ | Description | Description | |
8068
+ | Additional comments | Comments | |
8069
+ | State | Progress | |
8070
+ | Urgency | Severity | |
8071
+ | Others | Custom Fields | |
8072
+
8073
+ ### Status Mapping
8074
+
8075
+ | ServiceNow | Flashduty | Notes |
8076
+ | ----------- | ---------- | ---------------------- |
8077
+ | New | Trigger | |
8078
+ | In Progress | Processing | |
8079
+ | On Hold | Snoozed | Default snooze 2 hours |
8080
+ | Resolved | CLosed | |
8081
+ | Closed | CLosed | |
8082
+ | Canceled | CLosed | |
8083
+
8084
+ ### Priority Mapping
8085
+
8086
+ Only when ServiceNow's Urgency value changes will it affect Flashduty's Severity
8087
+
8088
+ | ServiceNow | Flashduty | Notes |
8089
+ | ---------- | --------- | ----- |
8090
+ | Low | Info | |
8091
+ | Medium | Warning | |
8092
+ | High | Critical | |
8093
+ `};n.FlashDocsEn=h})(window);
package/dist/iife/zh.js CHANGED
@@ -8106,4 +8106,286 @@ https://cmdb.com/vm?sn=VM123456
8106
8106
  1. 当引用的内容不存在时,Link 集成会正常生成对应的链接,但无法获取到值
8107
8107
  2. 同一个协作空间至多绑定三个 Link 集成
8108
8108
  3. 注意引用语法,如未按照要求进行书写引用变量,会导致无法正常获取对应值
8109
+ `,ServiceNowSync:`---
8110
+ title: "ServiceNow 同步"
8111
+ description: "通过 ServiceNow 同步 Webhook,实现故障与 ServiceNow Incident 的关联。"
8112
+ date: "2025-05-19T10:00:00+08:00"
8113
+ url: "https://docs.flashcat.cloud/zh/flashduty/service-now-sync"
8114
+ ---
8115
+
8116
+ 通过 ServiceNow 同步 Webhook,将 Flashduty 的故障与 ServiceNow Incident 进行关联同步,实现 Flashduty 与 ServiceNow 的联动。
8117
+
8118
+ ## 在 ServiceNow
8119
+
8120
+ ### 创建用户
8121
+
8122
+ 1. 登录 ServiceNow 实例控制台,通过选择 \`ALL\` ,输入 \`USERS\` 选择\`Organization\`-\`Users\` 。
8123
+ 2. 点击 \`New\` 新建用户。
8124
+ 3. 在编辑页面中,\`User ID\` 输入:flashduty 。
8125
+ 4. \`Password needs reset\` 和 \`Web service access only\` 以及 \`Internal Integration User\` 保持取消勾选状态。
8126
+ 5. 提交保存。
8127
+
8128
+ <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/snow/snow-1.png" />
8129
+
8130
+ ### 配置用户
8131
+
8132
+ 用于访问 ServiceNow 的用户需要是管理员角色。
8133
+
8134
+ 1. 在用户列表页面,找到新创建的 \`flashduty\` 用户并进到配置页面。
8135
+ 2. 在编辑页面中,点击 \`Set Password\` 设置一个密码。
8136
+ 3. 点击 \`Roles\` 添加 **admin 和 itil** 角色。
8137
+ 4. 点击 \`Update\` 更新配置。
8138
+
8139
+ <img alt="drawing" width="600" src="https://download.flashcat.cloud/flashduty/doc/snow/snow-2.png" />
8140
+
8141
+ ## 在 Flashduty
8142
+
8143
+ ### 配置集成
8144
+
8145
+ 将以上配置的用户名/密码以及实例名称输入到左侧集成信息中并点击下一步进行配置。
8146
+
8147
+ - **集成名称:** 为当前集成定义一个名称。
8148
+ - **管理团队:** 当选择管理团队后,只有该团队成员以及租户管理员可以编辑此集成。
8149
+ - **协作空间**:选择该集成生效的协作空间,。
8150
+ - **同步方向:**
8151
+ - To_ServiceNow:将 Flashduty 的故障同步至 ServiceNow。
8152
+ - From_ServiceNow:将 ServiceNow 的 Incident 同步至 Flashduty。
8153
+ - Two-way:Flashduty 和 ServiceNow 互相同步。
8154
+ - **触发模式**:
8155
+ - 自动触发:需要配置相应的条件,Flashduty 会自动将符合条件的故障同步到 ServiceNow 中。
8156
+ - 手动触发:需要在故障详情页的更多操作中手动触发 ServiceNow 同步(该集成配置的名称为触发器名称)。
8157
+ - **严重程度映射**:ServiceNow 的 Priority 是由 Impact 和 Urgency 的值共同决定的,所以可以参考 ServiceNow 的 \`Priority Lookup Rules\` 进行配置。另外需要注意的是,只有当 ServiceNow Incident 的 Urgency 发生变化时,才会触发 Flashduty 故障严重程度的更新。
8158
+ - **自定义字段映射**:可以选择将故障的某些标签或所有标签以及自定义字段内容同步至 ServiceNow 的字段中(仅支持文本类型的字段)。
8159
+
8160
+ ## 在 ServiceNow
8161
+
8162
+ 当同步方向选择 From_ServiceNow 或 Two-way 时,还需要在 ServiceNow 中做相应的配置,以便将 ServiceNow Incident 同步至 Flashduty, 在同步至 Flashduty 时,有以下两种方式,可根据实际需求选择即可。
8163
+
8164
+ ### 手动同步
8165
+
8166
+ 该方式依赖 ServiceNow 提供的 UI Action 和 Script Include 的配置,根据以下步骤配置完成的效果:当新建 Incident 或更新 Incident 时,可以在功能区看到发送同步请求的按钮,触发该按钮,可以将当前 Incident 的内容同步至 Flashduty。需要注意的是,如果触发请求时遇到失败的情况,请重试(重试时间间隔需大于 10 秒)。
8167
+
8168
+ #### 配置 UI Action
8169
+
8170
+ 1. 登录 ServiceNow 实例控制台,通过选择 \`ALL\` ,输入 \`UI Actions\` 选择\`System Definition\`-\`UI Actions\` 。
8171
+ 2. 点击 \`New\` 新建 Action。
8172
+ 3. \`Name\` 输入: **Send To Flashduty**, \`Table\` 选择 **Incident** 。
8173
+ 4. \`Form button\` ,\`Active\` ,\`Show insert\` ,\`Show update\` ,\`Client\`, \`List v2/3 Compatible\` 保持勾选状态。
8174
+ 5. \`Onclick\` 输入:**onClick();**。
8175
+ 6. \`Script\` 输入:
8176
+
8177
+ \`\`\`js
8178
+ function onClick() {
8179
+ g_form.save();
8180
+
8181
+ var ga = new GlideAjax("IncidentWebhookHelperAjax");
8182
+ ga.addParam("sysparm_name", "sendWebhook");
8183
+ ga.addParam("sysparm_sys_id", g_form.getUniqueValue());
8184
+
8185
+ ga.getXMLAnswer(function (response) {
8186
+ alert("Webhook Triggered: " + response);
8187
+ });
8188
+ }
8189
+ \`\`\`
8190
+
8191
+ 7. 提交保存。
8192
+
8193
+ #### 配置 Script Include
8194
+
8195
+ 1. 登录 ServiceNow 实例控制台,通过选择 \`ALL\` ,输入 \`Script Includes\` 选择\`System Definition\`-\`Script Includes\` 。
8196
+ 2. 点击 \`New\` 新建 Script Include。
8197
+ 3. \`Name\` 输入:**IncidentWebhookHelper** , \`Accessible from\` 选择 **All application scopes**。
8198
+ 4. \`Client callable\` 和 \`Active\` 保持勾选状态。
8199
+ 5. \`Script\` 输入以下内容,其中 **request.setEndpoint** 中需要补充集成的推送地址:
8200
+
8201
+ <div class="hide">
8202
+
8203
+ 注意: body 中配置的是默认接收字段,如果有自定义字段需要同步至 Flashduty ,需要额外手动补充内容到 body 中,比如希望添加一个字段名为:test_001 的字段(该字段名可以在配置集成中添加自定义字段的时候获取,不要使用 ServiceNow Inident 表单中显示的字段名),那么需要在 body 中补充:test_001: current.getDisplayValue("test_001")。
8204
+
8205
+ </div>
8206
+
8207
+ \`\`\`js
8208
+ var IncidentWebhookHelper = Class.create();
8209
+ IncidentWebhookHelper.prototype = {
8210
+ initialize: function() {},
8211
+
8212
+ sendIncidentWebhook: function(current) {
8213
+ function getLastComment(sysId) {
8214
+ var journalGR = new GlideRecord('sys_journal_field');
8215
+ journalGR.addQuery('element_id', sysId);
8216
+ journalGR.addQuery('element', 'comments');
8217
+ journalGR.orderByDesc('sys_created_on');
8218
+ journalGR.setLimit(1);
8219
+ journalGR.query();
8220
+ if (journalGR.next()) {
8221
+ return journalGR.getValue('value');
8222
+ }
8223
+ return '';
8224
+ }
8225
+
8226
+ var body = {
8227
+ action_type: current.isNewRecord() ? 'insert' : 'update',
8228
+ number: current.getValue("number"),
8229
+ sys_id: current.getUniqueValue(),
8230
+ short_description: current.getValue("short_description"),
8231
+ description: current.getValue("description"),
8232
+ impact: current.getDisplayValue("impact"),
8233
+ urgency: current.getDisplayValue("urgency"),
8234
+ comments: getLastComment(current.getUniqueValue()),
8235
+ <label name='field_mapping' tab='10'>{original.key}: current.getDisplayValue("{original.key}")</label>
8236
+ };
8237
+
8238
+ try {
8239
+ var request = new sn_ws.RESTMessageV2();
8240
+ request.setHttpMethod("POST");
8241
+ request.setEndpoint("PUSH URL");
8242
+ request.setRequestHeader("Content-Type", "application/json");
8243
+ request.setRequestBody(JSON.stringify(body));
8244
+ request.executeAsync();
8245
+ } catch (ex) {
8246
+ gs.error("Webhook Call failed: " + ex.message);
8247
+ }
8248
+ },
8249
+ type: 'IncidentWebhookHelper'
8250
+ };
8251
+
8252
+ \`\`\`
8253
+
8254
+ 6. 提交保存。
8255
+ 7. 回到 Script Includes 列表,继续创建。
8256
+ 8. 点击 \`New\` 新建 Script Include。
8257
+ 9. \`Name\` 输入:**IncidentWebhookHelperAjax** , \`Accessible from\` 选择 **All application scopes**。
8258
+ 10. \`Client callable\` 和 \`Active\` 保持勾选状态。
8259
+ 11. \`Script\` 输入以下内容:
8260
+
8261
+ \`\`\`js
8262
+ var IncidentWebhookHelperAjax = Class.create();
8263
+ IncidentWebhookHelperAjax.prototype = Object.extendsObject(
8264
+ global.AbstractAjaxProcessor,
8265
+ {
8266
+ sendWebhook: function () {
8267
+ var sysId = this.getParameter("sysparm_sys_id");
8268
+ var gr = new GlideRecord("incident");
8269
+ if (gr.get(sysId)) {
8270
+ var helper = new IncidentWebhookHelper();
8271
+ helper.sendIncidentWebhook(gr);
8272
+ return "Success";
8273
+ }
8274
+ return "Request failed";
8275
+ },
8276
+ }
8277
+ );
8278
+ \`\`\`
8279
+
8280
+ 12. 提交保存。
8281
+
8282
+ ### 自动同步
8283
+
8284
+ 该方式依赖 ServiceNow 提供的 Business Rules 的配置,使用该方式可以实现当有新建或更新事件时,自动将 Incident 同步至 Flashduty。
8285
+
8286
+ #### 配置 Business Rules
8287
+
8288
+ 1. 登录 ServiceNow 实例控制台,通过选择 \`ALL\` ,输入 \`Business Rules\` 选择\`System Definition\`-\`Business Rules\` 。
8289
+ 2. 点击 \`New\` 新建 Business Rule。
8290
+ 3. \`Name\` 输入:**Send To Flashduty** , \`Table\` 选择 **Incident**。
8291
+ 4. \`Advanced\` 和 \`Active\` 保持勾选状态。
8292
+ 5. 在 \`When to run\` 区域中,\`When\` 选择 **async**,\`Insert\` 和 \`Upsert\` 保持勾选状态,其他按需配置。
8293
+ 6. 在 \`Advanced\` 区域中,\`Script\` 填写以下内容,其中 **endpoint** 中需要补充集成的推送地址:
8294
+
8295
+ <div class="hide">
8296
+
8297
+ 注意: body 中配置的是默认接收字段,如果有自定义字段需要同步至 Flashduty ,需要额外手动补充内容到 body 中,比如希望添加一个字段名为:test_001 的字段(该字段名可以在配置集成中添加自定义字段的时候获取,不要使用 ServiceNow Inident 表单中显示的字段名),那么需要在 body 中补充:test_001: current.getDisplayValue("test_001")。
8298
+
8299
+ </div>
8300
+
8301
+ \`\`\`js
8302
+ (function executeRule(current, previous) {
8303
+ function getLastComment(recordSysId) {
8304
+ var journalGR = new GlideRecord("sys_journal_field");
8305
+ journalGR.addQuery("element_id", recordSysId);
8306
+ journalGR.addQuery("element", "comments");
8307
+ journalGR.orderByDesc("sys_created_on");
8308
+ journalGR.setLimit(1);
8309
+ journalGR.query();
8310
+ if (journalGR.next()) {
8311
+ var comment = journalGR.getValue("value");
8312
+ return comment;
8313
+ }
8314
+ return "";
8315
+ }
8316
+
8317
+ var operation = current.operation() || "unknown";
8318
+ var isPreviousNull = previous === null;
8319
+ var createdOn = current.getValue("sys_created_on");
8320
+ var updatedOn = current.getValue("sys_updated_on");
8321
+ var isNewRecord = createdOn === updatedOn;
8322
+
8323
+ var action = "update";
8324
+ if (isPreviousNull && isNewRecord) {
8325
+ action = "insert";
8326
+ }
8327
+
8328
+ var body = {
8329
+ action_type: action,
8330
+ number: current.getValue("number"),
8331
+ sys_id: current.getUniqueValue(),
8332
+ short_description: current.getValue("short_description"),
8333
+ description: current.getValue("description"),
8334
+ state: current.getDisplayValue("state"),
8335
+ impact: current.getDisplayValue("impact"),
8336
+ urgency: current.getDisplayValue("urgency"),
8337
+ comments: getLastComment(current.getUniqueValue()),
8338
+ <label name='field_mapping' tab='4'>{original.key}: current.getDisplayValue("{original.key}")</label>
8339
+
8340
+ };
8341
+
8342
+ try {
8343
+ var endpoint = "";
8344
+ var request = new sn_ws.RESTMessageV2();
8345
+ request.setHttpMethod("POST");
8346
+ request.setEndpoint(endpoint);
8347
+ request.setRequestHeader("Content-Type", "application/json");
8348
+ request.setRequestBody(JSON.stringify(body));
8349
+ request.executeAsync();
8350
+ } catch (ex) {
8351
+ gs.error("Error sending webhook: " + ex.message);
8352
+ }
8353
+ })(current, previous);
8354
+ \`\`\`
8355
+
8356
+ 7. 提交保存。
8357
+
8358
+ ## 同步信息
8359
+
8360
+ ### 表单字段
8361
+
8362
+ | ServiceNow | Flashduty | 备注 |
8363
+ | ------------------- | ------------- | ---- |
8364
+ | Short_description | Title | |
8365
+ | Description | Description | |
8366
+ | Additional comments | Comments | |
8367
+ | State | Progress | |
8368
+ | Urgency | Severity | |
8369
+ | Others | Custom Fields | |
8370
+
8371
+ ### 状态映射
8372
+
8373
+ | ServiceNow | Flashduty | 备注 |
8374
+ | ----------- | ---------- | --------------- |
8375
+ | New | Trigger | |
8376
+ | In Progress | Processing | |
8377
+ | On Hold | Snoozed | 默认暂缓 2 小时 |
8378
+ | Resolved | CLosed | |
8379
+ | Closed | CLosed | |
8380
+ | Canceled | CLosed | |
8381
+
8382
+ ### 优先级映射
8383
+
8384
+ 只有 ServiceNow 的 Urgency 值变化时,才会影响 Flashduty 的 Severity
8385
+
8386
+ | ServiceNow | Flashduty | 备注 |
8387
+ | ---------- | --------- | ---- |
8388
+ | Low | Info | |
8389
+ | Medium | Warning | |
8390
+ | High | Critical | |
8109
8391
  `};n.FlashDocsZh=t})(window);
package/dist/zh.d.ts CHANGED
@@ -61,5 +61,6 @@ declare const docs: {
61
61
  DingtalkAlert: string;
62
62
  FeishuAlert: string;
63
63
  Link: string;
64
+ ServiceNowSync: string;
64
65
  };
65
66
  export default docs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashduty-knowledge-base",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "flashduty knowledge base",
5
5
  "type": "module",
6
6
  "engines": {