0
0

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 - 重複したレコード一覧を作成する

Posted at

概要

ServiceNowでフィールドをユニークにしようとしたら重複したレコードエラーになると言う問い合わせがServiceNowフォーラムでありました。
重複したレコードを検出するスクリプトを作成しました。

アプリケーションナビゲータから「スクリプト - バックグラウンド」を開いて実行すると重複したレコード一覧が表示されます。

var uniqueField= 'state';
var tableName = 'incident';

var count = new GlideAggregate(tableName);
count.addAggregate('COUNT', uniqueField);
count.query();  
while (count.next()) {
   var fieldValue= count[uniqueField];
   var fieldCount = count.getAggregate('COUNT', uniqueField);
   gs.info("Number of duplicates " + fieldCount + ' value:' + fieldValue);
}
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?