LoginSignup
1
2

More than 3 years have passed since last update.

[ServiceNow] 任意のクエリーで取得したリストを関連リストに表示する方法

Last updated at Posted at 2020-10-16

概要

ServiceNow の画面には、関連リストという最下部のエリアで、今開いているレコードと関連する別レコードのリストを表示できるようになっています。
こちらのエリアには、基本的には、今開いているレコードへの Reference フィールドを持っているテーブルが表示対象として選択できるようになっていますが、Relationship という定義で設定すると、任意のクエリーで関連するレコードを取得し、表示することができます。

既存の各 Relationship の定義は、System Definition > Relationships に行くことで確認することができます。
例えば、Incident テーブルに対しては、「Incident by Same Caller」という Relationship が定義されています。
image.png
Apply to table の方が、関連リストを出すときの親テーブルになるもの、Queries from Table が関連リストを取得する対象の子テーブルです。
「Incident by Same Caller」という関係は、Apply to table、Queries from Table ともに Incident で、以下のスクリプトがクエリーのスクリプトとして、定義されています。

current.addQuery('caller_id', parent.caller_id);

ですので、Incident レコードを開いたときに、開いたインシデントレコードのcaller_id フィールドの値と同じ値が caller_id に入っている Incident をクエリーして表示する Relationship になっています。

定義されている Relationship は、関連リストを表示した画面で、ヘッダー部分を右クリック、Configure > Related list と行って、出てくる画面で表示する候補として出てきます。
image.png
image.png

自分で Relationship を追加した場合も候補に出てきますので、任意のクエリーで取得したリストを関連リストに表示できます。

以上です。

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