Service Now勉強記録

Service Nowの勉強記録です

Service Now GlideRecord データベースの値ではなく、画面表示と同じ形式でデータを取得する getDisplayValue()

■ サンプル

var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('priority', 1);
incidentGR.query();
while(incidentGR.next()){
  gs.debug(incidentGR.number + '/' + incidentGR.priority);
}

 

Service Now GlideRecored priorityは 設定値は表示される

 

 

■ getDisplayValue()を使う

var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('priority', 1);
incidentGR.query();
while(incidentGR.next()){
  gs.debug(incidentGR.number + '/' + incidentGR.priority.getDisplayValue());
}

 

1ではなく、 1 - Critical が表示されるようなった

 

Service Now Grid Record insert

■Service Now GlideRecord insert コードサンプル

var incidentGR = new GlideRecord('incident');
incidentGR.query();
incidentGR.newRecord();
incidentGR.short_description = 'TEST 123';
incidentGR.insert();

 

Service Now Scripts Backgroundでの実行結果

 

 

■ Service Now GlideRecord update コードサンプル

var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('priority','1');
incidentGR.query();
while(incidentGR.next()){
  incidentGR.priority = '3';
  incidentGR.update();
}

 

■ Service Now GlideRecord delete コードサンプル

var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('priority','1');
incidentGR.query();
while(incidentGR.next()){
  incidentGR.deleteRecord();
}

 

 

 

 

Servicew Now Workflowsとは

  • サーバー側で起動
  • シリアルに実行(ワークフロー)

 

Service Now Workflows新規作成画面

 

上記でSubmit押下で下記の画面が表示される

Service Now Workflows エディタ画面

 Activityを追加

 

 

各ActivityとWorkflowを接続していく

 

 

Service Now Script Includesとは

  • サーバー側で動作
  • JavaScriptのクラス、関数
  • 再利用可能

 

Service Now Script Includes 設定画面
  • クラスではないスクリプトの場合、サーバー側での実行のみ
  • クラスの場合は、サーバー側、クライアント側から利用できる
    • <classname>.prototype = Object.extendsObject(<extendingClassName>,{/* ここにスクリプト書く*/});

Servicew Now UI Policiesとは

  • クライアント側で動作
  • 主にフォーム上で使う。フィールド属性として Read-Only、必須など

Service Now UI Policies メニュー

IncidentテーブルのUI Policies一覧



  • テーブルを設定
  • 条件を設定 (When to apply のConditions)

Service Now UI Policies 設定(When to apply)

スクリプトを設定

Service Now UI Policies 設定(Script)