LoginSignup
2
1

More than 3 years have passed since last update.

[ServiceNow] スケジュールジョブを Update Set に記録する方法

Posted at

概要

スケジュージョブを新規作成、更新しても、Update Set には記録されませんが、開発環境で実装したスケジュールジョブを他の開発物とともに一緒に Update Set に入れて移行させたい場合も多いです。
本記事では、スケジュールジョブを Update Set に記録する方法を説明します。

手順

1 スケジュールジョブを記録させたい Update set をピッカーで選んでおきます
2 System Definition > Scheduled job に行き、Update Set に記録させたいスケジュールジョブを右クリック -> Copy sys_id を選んで、記録させたいスケジュールジョブの sys_id をコピーしておきます
3 System Definition > Script - Background に行き、以下のスクリプトを実行します

var gr = new GlideRecord('sysauto_script'); 
if(gr.get('<対象ジョブのsys_id>')){ 
gs.updateSave(gr); 
}

4 System Update Sets > Local Update Sets 行き、スケジュールジョブを記録した Update Set を開き、スケジュールジョブが記録されていることを確認します
image.png
以上です。

補足

補足1

gs.updateSaveメソッドは、global スコープでしか動きません。Scoped App に作ったScheduled jobを記録したい場合は、ピッカーのアプリとUpdate set は記録したいScoped Appのものを選んでおき、Script - Background でスクリプトを走らせる画面で、in scope に global を選んで実行します。
こうすることで、global スコープでスクリプトが実行されるため、gs.updateSaveメソッドが動き、スケジュールジョブが記録される Update Set は、ピッカーで選んでおいた Scoped App の Update Set になります。

補足2

リポジトリを使って、Scoped app を移行させた場合や、Scoped app をまるごと、Update set に Publish した場合は、その Scoped app に含まれるスケジュールジョブも移行対象として含まれます。

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