4
6

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 5 years have passed since last update.

ServiceNow-Choiceの値をUI Policyで出しわけたい時

Posted at

ServiceNow開発における実装上の課題と解決法を書いておきます。

  • 課題は、実装上で実際にぶち当たった方法論です。
  • 問題は、OOTB(Out of the box)環境において再現可能であることを前提にします。

それでは行ってみましょう。

#課題
Choice listの値を、他のFieldの値に応じて動的に出しわけたい
##課題
incidentテーブルのCategoryフィールドの値を変更すると、SubCategoryフィールドに出る選択肢が動的に変化すること

画像

FireShot Capture 139 - INC0009009 - Incident - ServiceNow - dev95965.service-now.com.png

1.スクリプトで実装する場合

  • g_form.addOption()
  • g_form.removeOption()

をUI Policyで活用する。
条件付け
FireShot Capture 141 - UI Policy - ServiceNow - dev95965.service-now.com.png
スクリプト

function onCondition() {
        //要らないものを削除
	g_form.removeOption('subcategory','operation_system');
	g_form.removeOption('subcategory','cpu');
        //いるものを追加
        g_form.addOption('subcategory','email');
}

終始、このノリで書ける。

2.OOTBで行う場合

subcategoryフィールドのdictioaryを開いて、そこにあるdependentタブにdependentフィールドが指定できるので、categoryを指定。
そして、下の関連リストにsubcategoryの全量を指定。
関連リストの一番右にdependencyカラムが存在するので、そこでCategoryの対応するvalueを指定すること。

こちらのほうがOOTBベースの実装である。

4
6
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
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?