LoginSignup
0
1

More than 1 year has passed since last update.

ServiceNow - GlideRecord使用方法

Posted at

1.Scripts - Backgroundを開く

[System Definition] > [Scripts - Background]
image.png
任意のScriptを実行できるモジュール。これでGlideRecordの動作を確認する。
image.png

2.GlideRecordクラスの変数を作成する

変数宣言時にテーブルを指定する。
今回はIncidentテーブルを検索する。

Script
var gr = new GlideRecord('incident');

3.検索条件を設定する

「Short Description = "TEST" and Priority = 1 - Critical」の条件を設定する。

Script
var gr = new GlideRecord('incident');
gr.addQuery('short_description', 'TEST');
gr.addQuery('priority', '1');

4.検索を実行する

query()で実際に検索が行われる。
また、実行確認用のScriptも追記する。

Script
var gr = new GlideRecord('incident');
gr.addQuery('short_description', 'TEST');
gr.addQuery('priority', '1');
gr.query();

gs.info("[Number], [Short Description], [Priority]");
while (gr.next()) {
	gs.info(gr.getValue('number')
	+ ", " + gr.getValue('short_description')
	+ ", " + gr.getValue('priority'));
}

5.確認

[Scripts - Background]にて、Run scriptボタンを押下し、Scriptを実行する。
image.png

一覧画面での検索結果
image.png

0
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
0
1