Loading
程式設計工作叫用

程式設計工作叫用

使用 VlocityBatchFramework 方法以使用「查詢」的「資料來源類型」來開始排程工作。您可以開始所有工作、多個工作或單一工作。您也可以叫用整合程序或 VlocityOpenInterface 作為工作。

若要立即啟動具有「資料來源類型」查詢的所有排程工作,請使用匿名 Apex 叫用 VlocityBatchFramework.startScheduledJobs() 方法,省略任何參數,如下所示:

VlocityBatchFramework.startScheduledJobs();

若要立即使用「資料來源類型」查詢來開始單一排程工作,請使用匿名 Apex 叫用 VlocityBatchFramework.startScheduledJob() 方法,指定您要執行工作的識別碼。例如:

VlocityBatchFramework.startScheduledJob('a3Zf4000000J81v');

若要立即啟動具有「資料來源類型」查詢的多個排程工作,請使用匿名 Apex 叫用 VlocityBatchFramework.startScheduledJobs() 方法,指定您要執行之工作的識別碼清單。例如:

VlocityBatchFramework.startScheduledJobs(new List<Id>{'a3Zf4000000J81v', 'a3Zf4000000IwIU'});

備註
備註 批次架構不支援使用「無輸入」、「資料輸入」或「清單輸入」值的「資料來源類型」來叫用已排程工作。

批次架構也可讓您以程式設計的方式叫用任何「整合程序」或 VlocityOpenInterface 作為工作。開始批次工作的方法如下:

VlocityBatchFramework.startIntegrationProcedureBatch(String integrationProcedureKey, List<Object> input, new Map<String, Object> options);
VlocityBatchFramework.startOpenInterfaceBatch(String classMethod, List<Object> input, new Map<String, Object> options);

若要從 Apex 開始整合程序工作,請發出下列指令:

VlocityBatchFramework.startIntegrationProcedureBatch({integration procedure key}, input list, options map);

例如:

VlocityBatchFramework.startIntegrationProcedureBatch('VlocityBatchFramework_ValidateAccountBillingStreet', accounts, new Map<String, Object>{'isInputAsList' => true, 'batchSize' => 20});

若要啟動執行指定類別之 invocateMethod 的非同步 Apex 工作,請發出下列指令:

VlocityBatchFramework.startOpenInterfaceBatch({ Class name . method name }, input list, options map);

例如:

VlocityBatchFramework.startOpenInterfaceBatch('VlocityBatchFrameworkTestOI4.updateStatus', accounts, new Map<String, Object>{'isInputAsList' => false, 'batchSize' => 20});

若要鏈結執行「整合程序」的已排程工作,請提供工作的識別碼,並包含設為 true 的可鏈結選項:

startScheduledJobs(new Map<String, Object>{‘vlocityScheduledJobIds’ => new List<String>{‘JobId’, 'JobId2'}, new Map<String, Object>{'chainable' => true});

例如:

VlocityBatchFramework.startScheduledJobs(new Map<String, Object>{'vlocityScheduledJobIds' => new List<String>{'a3Zf4000000T7A1', 'a3Zf4000000T7A6'}}, new Map<String, Object>{'chainable' => true});

以程式設計的方式叫用工作時,您可以在選項對應中指定下列選項。如需詳細資料,請參閱上方。

  • batchSize

  • chainable:只有包含「整合程序」的工作可以鏈結。

  • isInputAsList

  • jobQueue

下列方法可讓您以程式設計的方式管理工作執行:

  • getCurrentBatchJobs():傳回非「已中止」、「已完成」或「失敗」的 AsyncApexJobs。

  • abortBatchJobs():中止所有名為「VlocityBatchFramework」的 AsyncApexJobs。

  • getScheduledBatchJob():傳回名為「VlocityScheduledJob」的 CronTrigger。

  • abortScheduledBatchJob():嘗試中止名為「VlocityScheduledJob」的 CronTrigger。

 
正在載入
Salesforce Help | Article