728x90
Salesforce에서 작성한 Batch의 스케줄 생성 시 Batch Class를 직접 선언하지 않고, Class Name의 String 값을 가지고, Type.forname()를 이용하여 동적으로 newInstance를 생성해 실행할 수 있습니다.
// 일반적인 스케줄 생성
SampleBatch sampleBatch = new SampleBatch();
String SCH_NAME = 'Sample Batch Schedule';
String SCH_TIME = '0 0 1 * * ?'; // 매일 1:00
system.schedule(SCH_NAME, SCH_TIME, sampleBatch);
// 동적 스케줄 생성
String SCH_BATCH = 'SampleBatch';
String SCH_NAME = 'Sample Batch Schedule';
String SCH_TIME = '0 0 1 * * ?'; // 매일 1:00
system.schedule(SCH_NAME, SCH_TIME, (Schedulable)Type.forname(SCH_BATCH).newInstance());
728x90
'Salesforce > Tips' 카테고리의 다른 글
Quickly enter number and currency fields in Salesforce (Salesforce에 숫자 및 통화 필드를 빠르게 입력) (0) | 2023.05.14 |
---|---|
Salesforce Keyboard Shortcuts (세일즈포스 키보드 바로 가기) (0) | 2023.05.12 |
세일즈포스 배치 동적 실행 (Salesforce batch dynamic execution) (0) | 2021.04.12 |