5
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でレコードを複製したい

Last updated at Posted at 2020-08-04

最近ServiceNowを利用した運用ツール開発に関わってまして、その中で知っておくと便利な知見をまとめておこうかと思います。

今回はレコードを複製したい場合。

ちょいちょいケースとして存在するので調べてみるとかなり短いスクリプトでやれそうです。

var sourceRecordSysID = "[sys_id of your record here]",
	tableName = "[your table name here]";

var gr = new GlideRecord(tableName);

gr.initialize();
gr.get(sourceRecordSysID);
gr.insert();

ではこれをどこに書くかというと色々考えられますが、私は Scheduled Jobs でやりました。

  • Filter Navigator(左メニューの検索窓)で Scheduled Jobs と入力
  • メニューをクリック後、Table上部の New をクリック
  • Automatically run a script of your choosing を選択
  • Run Fieldの値を On Demand に変更(必要に応じて実行するモード)
  • Run this script Fieldに上記のスクリプトを貼り付けてSubmit

この状態で再度スクリプトを開いて、 Execute Now を選択すると、指定したTableのレコードが複製されると思います。

5
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
5
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?