1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ServiceNow - スクリプトが利用されているスクリプトを検索する

Last updated at Posted at 2020-11-11

概要

スクリプトが呼び出されている他スクリプトを探すスクリプトです。
全文検索でスクリプトが利用されている可能性があるテーブルを検索する。但し、Flow DesignerやWorkflowからの呼び出されている箇所は対象外になります。

スクリプト用テーブルの全文検索

var searchString = '<検索する文字列>';  // 例:GetUserInfo

var tableList = ['sys_script_client','sys_ui_policy','sys_ui_script','catalog_ui_policy','sys_widgets','sys_ui_page',
'sys_script','sys_script_include','sysevent_script_action','sysauto','sys_script_fix',
'sys_script_email','sys_installation_exit','sp_widget','sys_security_acl','sys_transform_script',
'sys_transform_entry','sys_ui_action','sys_ui_page','sys_ui_macro','sys_ws_definition','sys_script_validator'];

tableList.forEach(searchText);


function searchText(tableName) {
  gs.info(tableName + '*************************');
  var gr = new GlideRecord(tableName);
  gr.addQuery('IR_AND_OR_QUERY', searchString);
  gr.query();
  while (gr.next()) {
    gs.info(tableName + ':' + gr.name);
  }
}

GITを利用する

ServiceNow Studioでgitを利用してソースコード管理をするとgrepでnewをしている行を検索することもできます。

スクリプトを含むテーブル一覧

No. 名前 テーブル名 継承
1 Client Scripts sys_script_client
2 UI Policy sys_ui_policy
3 UI Scripts sys_ui_script
4 Catalog Client Script catalog_script_client Client Scripts
5 Catalog UI Policy catalog_ui_policy UI Policy
6 Widget client script sys_widgets
7 UI Pages - Client script sys_ui_page
8 Business rule sys_script
9 Script include sys_script_include
10 Script action sysevent_script_action
11 Schedule job sysauto
12 Fix Scripts sys_script_fix
13 Workflow run script -
14 Email Scripts sys_script_email
15 Installation Exits sys_installation_exit
16 Widget server side script sp_widget
17 ACL Script sys_security_acl
18 Transform map scripts sys_transform_script
19 Field map scripts sys_transform_entry
20 UI Actions sys_ui_action
21 UI Pages - Processing script sys_ui_page
22 UI Macros sys_ui_macro
23 Scripted REST APIs sys_ws_definition
24 Validation Scripts sys_script_validator
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?