global class PowerBIUpdateBatch implements Database.Batchable<sObject> {
|
|
String query;
|
Id targetId;
|
|
Boolean IsNeedExecute = false; // 2021-03-05 mzy WLIG-BYHD79 SFDC环境batch合并调查 是否符合执行条件
|
|
global PowerBIUpdateBatch(Id targetid) {
|
this.targetId = targetid;
|
}
|
|
global PowerBIUpdateBatch(Boolean needExecute) {
|
IsNeedExecute = needExecute; // 2021-03-05 mzy WLIG-BYHD79 SFDC环境batch合并调查
|
}
|
|
global Database.QueryLocator start(Database.BatchableContext BC) {
|
query = 'select Id, ShareWithPowerBI__c, ShareWithPowerBIFormula__c, ShareWithPowerBI_NeedUpd__c';
|
query += ' from BI_OpportunityLineItem__c';
|
query += ' where ShareWithPowerBI_NeedUpd__c = true';
|
if (targetId != null) {
|
query += ' and OpportunityId__c = \'' + targetId + '\'';
|
}
|
return Database.getQueryLocator(query);
|
}
|
|
global void execute(Database.BatchableContext BC, List<sObject> scope) {
|
List<BI_OpportunityLineItem__c> updateList = new List<BI_OpportunityLineItem__c>();
|
for (SObject obj: scope) {
|
BI_OpportunityLineItem__c bi_oli = (BI_OpportunityLineItem__c) obj;
|
bi_oli.ShareWithPowerBI__c = bi_oli.ShareWithPowerBIFormula__c;
|
updateList.add(bi_oli);
|
}
|
|
if (updateList.size() > 0) update updateList;
|
}
|
|
global void finish(Database.BatchableContext BC) {
|
|
//2021-03-05 mzy WLIG-BYHD79 SFDC环境batch合并调查 start
|
if(!Test.isRunningTest() &&IsNeedExecute==true){
|
//batch里调用下一个batch时,希望跟原有的Schedule里面传的条数保持一致
|
Id execBTId = Database.executebatch(new ConsumAutoCancelRequestBatch(true));
|
}
|
//2021-03-05 mzy WLIG-BYHD79 SFDC环境batch合并调查 end
|
|
|
}
|
|
}
|