我從查詢中獲取1561條記錄,現在我想在其他函數中傳遞記錄標識,並根據我們傳遞給此函數的特定標識檢索其他記錄System.LimitException:太多的SOQL查詢:101
我不明白,我可以使用地圖或其他方法來標識傳遞到其他功能,使Salesforce的限制不能實施
我也分享我的一小段代碼:
SendUpdateEmailList = [SELECT Id,
Update72Hrs_email__c,
File_Number__c,
Loan_Number__c,
Client_ID__c,
Borrower_Name__c,
Order_Status__c,
Current_Status_Notes__c,
Time_Since_Last_Updated__c
FROM Etrac_Orders__c
WHERE Order_Status__c!='Completed'
AND Order_Status__c!='Cancelled'
AND Order_Status__c!='Delayed by Borrower'
AND Order_Status__c!='On Hold'
AND Time_Since_Last_Updated__c > 72
AND IsDeleted <> true ];
system.debug('SendUpdateEmailList>>>>>>>>>>'+SendUpdateEmailList);
// map<id,string> myAMap = new map<id,string>();
for (Etrac_Orders__c c:SendUpdateEmailList){
myAMap.put(c.Id,c.File_Number__c);
}
for (ID aID : myAMap.keySet()){
myAMap.get(aID);
system.debug('<<<<<<<<<<aID'+aID);
workFlowChecker(aID); //this statement creates the limitation problem
}
public void WorkFlowChecker(ID id) {
system.debug('WorkFlowChecker-id>>>>>>>' + id);
datetime systemtime = System.now();
system.debug('systemtime>>>>>>>>>>>' + systemtime);
//date mydate = Date.ValueOf();
//datetime systemdate = dDate.format('MM/dd/yyyy hh: mm: ss a');
try {
workFlow = [SELECT Id,
Executed__c,
OrdersID__c,
Executed_Date__c,
WorkflowName__c From Workflow__c Where WorkflowName__c = 'Update72Hrs_email' AND OrdersID__c = : id Order by Executed_Date__c DESC Limit 1];
system.debug('workFlow>>>>>>>' + workFlow);
// system.debug('Executed_Date__c>>>>>>>>'+workFlow.Executed_Date__c);
for (Workflow__c record : workFlow) {
string WorkFlowId = record.Id;
Boolean Executed = record.Executed__c;
string OrdersID = record.OrdersID__c;
datetime Executed_Date = record.Executed_Date__c;
}
return;
} catch (QueryException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'No Record Found'));
return ;
}
}
在workflowChecker中會發生什麼?嘗試設計該功能,以便可以根據批量接收的數據處理其邏輯。 –