LoginSignup
7
5

More than 5 years have passed since last update.

Salesforce APEXをスケジュール登録する方法

Posted at

SalesforceでApexをスケジュール登録する方法のメモ

やりたいこと

・SalesforceでApexを定期的に走らせる

前提条件

・Schedulableをimplementsしたクラスを作成しておく

方法1:Salesforceの画面上で登録

Apexクラスの一覧画面を表示して、Apexをスケジュールをクリック。
image.png

ジョブ名(日本語を含んでもOK)、Schedulableをimplementsしたクラスを選択し、スケジュールを登録する。
image.png

方法2:開発者コンソールから登録

方法1だと開始日と終了日が必須になるので、終了日が未定の場合はこちらを使用します。
開発者コンソールからDebugタブ>Open Execute Anonymous Windowを選択
image.png
登録用コードを書いて、Executeを実行します。

// スケジュールを登録する
ScheduleTestBatch batch = new ScheduleTestBatch();
// 5時に実行
String sch = '0 0 5 1 * ?';
String scheduleId = System.schedule('ジョブ名', sch, batch);

image.png

確認方法

設定画面のジョブ>スケジュール済みジョブで確認できます。

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