I have to update bulk records by apex class which is called from an apex trigger. Please find my class and trigger below. Batch class:

global class UpdateAccountArea implements Database.Batchable<sObject> {
Map<Id,Id> updatedHCPMap = new Map<Id,Id>();

global UpdateAccountArea(Map<Id,Id> updatedMap) {
updatedHCPMap = updatedMap;

global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator([SELECT Id,Depth_Account__c 
                FROM HCP_Depth_Tracker_OAPI__c
                WHERE Depth_Tracker_OAPI__c IN : updatedHCPMap.keySet()]);

global void execute(Database.BatchableContext BC,List<HCP_Depth_Tracker_OAPI__c> scopeAcc) {

for (Integer i=0;i<scopeAcc.size();i++){
update scopeAcc;

global void finish(Database.BatchableContext BC) {

Apex trigger:

trigger HCPREFERENCE2 on Depth_Tracker_OAPI__c (after insert,after update) {
    List<HCP_Depth_Tracker_OAPI__c> updateTaskList = new List<HCP_Depth_Tracker_OAPI__c>();
    List<HCP_Depth_Tracker_OAPI__c> TaskList = new List<HCP_Depth_Tracker_OAPI__c>();
    Map<Id,Id> updatedMap = new Map<Id,Id>();

    for (Integer i=0;i<Trigger.new.size();i++) {
    Database.executeBatch(new UpdateAccountArea(updatedMap ));

I am getting below error here in the class.

Error: Compile Error: Initial term of field expression must be a concrete SObject: Id at line 17 column 91

Can someone help me here?

1 Answer 1


updatedHCPMap is declared as Map<id,id>.

And then you are doing


updatedHCPMap.get(scopeAcc.get(i).Depth_Tracker_OAPI__c) will get you an Id Value for that Key. If it was a Map<id, someObject__c> then what you did would have been correct.

I am not sure what you want to achieve so can't be sure as to what you need to change. But this the reason for you to get that error.

  • Hi AslamK. Thanks it worked. trigger execution fails all records as below. System.LimitException: Attempted to schedule too many concurrent batch jobs in this org (limit is 5).Can you please suggest a workaround for this? Aug 27, 2014 at 10:57
  • 2
    Hi @saikat, that's a different problem entirely, so I would suggest you mark AslamK's answer as the answer to the original question & then post a new question with the full details of this new error. Aug 27, 2014 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .