function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Somasundaram SubramanianSomasundaram Subramanian 

batch job value of list

am new to development , in below code they are getting values in Projects and using this projects value in soql query 
am new to development, what will be the value of projects in below code
  global void execute(Database.BatchableContext BC, List<pse__Proj__c> projects){

        date M_TDate = date.today();//Today Date               
        date M_SWDate = M_TDate.toStartofWeek();//Start Date of week      
        date M_EWDate = M_SWDate.addDays(6);//End Date of Week
        
        set <string> ResourceRequestStatus= new set <string> {'Ready to Staff'};        
        set <string> TimePeriodType = new set <string> {'Week'};
        
        map<Id,set<Id>> mapAssignmentEVA = new map<Id,set<Id>>();
        
        map<Id,set<Id>> mapRREVA = new map<Id,set<Id>>();
        
        map<Id,set<Id>> mapMilestoneRREVA = new map<Id,set<Id>>();
        map<Id,set<Id>> mapMilestoneEVA = new map<Id,set<Id>>();
        
        map<Id,set<Id>> mapBudgetRREVA = new map<Id,set<Id>>();
        map<Id,set<Id>> mapBudgetEVA = new map<Id,set<Id>>();
        
        map<Id,pse__Resource_Request__c> mapRRforRR = new map<Id,pse__Resource_Request__c>([select Id, pse__Project__c,pse__SOW_Hours__c, pse__Requested_Bill_Rate__c, pse__Assignment__c, pse__Milestone__c
        from pse__Resource_Request__c  where pse__Status__c IN: ResourceRequestStatus and pse__Project__c IN: projects]);
HarshHarsh (Salesforce Developers) 
Hi Somasundaram,

Can you explain a little bit more, that will be very helpful to me to understand your queries.

Thanks
Somasundaram SubramanianSomasundaram Subramanian
 @harsh
I got 50001 governor limit in the below line , so i would like to know how they are getting this "Projects" i want to reduce the collection in this soql , 
  map<Id,pse__Resource_Request__c> mapRR = new map<Id,pse__Resource_Request__c>([select Id, pse__Project__c,pse__SOW_Hours__c, pse__Requested_Bill_Rate__c 
        from pse__Resource_Request__c  where pse__Status__c IN: ResourceRequestStatus and pse__SOW_Hours__c > 0
 and pse__Project__c IN: projects]);
HarshHarsh (Salesforce Developers) 
Hi,
  • The total number of records retrieved by SOQL queries for synchronous Apex and asynchronous Apex is 50000. This is the per-transaction limit, and not a per-query limit.
  • SOQL calls should be filtered. They should have a WHERE clause and LIMIT which could prevent this exception.
  • One most important thing that everyone misses out on is Aggregate queries thinking, it is returning only the aggregate rows but queries with aggregate functions count each row used by the aggregation(as a query row) for limit tracking.
  • Use these following debug statements to check query rows governor limit of your org and the rows queried so far in your code.
    •  System.debug(‘Total number of records retrieved by SOQL queries:’+Limits.getLimitDmlRows());
    • System.debug(‘Number of records retrieved by SOQL queries so far: ‘ + Limits.getDmlRows());
Please mark it as Best Answer if the above information was helpful.

Thanks.
 
Somasundaram SubramanianSomasundaram Subramanian
I understand it but i would like to know in the below code they used pse__Project__c IN: projects]) , what will be the value in Projects by seeing below code could you pls tell me how the project value is added global void execute(Database.BatchableContext BC, List projects){ date M_TDate = date.today();//Today Date date M_SWDate = M_TDate.toStartofWeek();//Start Date of week date M_EWDate = M_SWDate.addDays(6);//End Date of Week set ResourceRequestStatus= new set {'Ready to Staff'}; set TimePeriodType = new set {'Week'}; map> mapAssignmentEVA = new map>(); map> mapRREVA = new map>(); map> mapMilestoneRREVA = new map>(); map> mapMilestoneEVA = new map>(); map> mapBudgetRREVA = new map>(); map> mapBudgetEVA = new map>(); map mapRRforRR = new map([select Id, pse__Project__ c,pse__SOW_Hours__c, pse__Requested_Bill_Rate__c, pse__ Assignment__c, pse__Milestone__c from pse__Resource_Request__c where pse__Status_ _c IN: ResourceRequestStatus and pse__Project__c IN: projects]); map mapRRforRR = new map([select Id, pse__Project__ c,pse__SOW_Hours__c, pse__Requested_Bill_Rate__c, pse__ Assignment__c, pse__Milestone__c from pse__Resource_Request__c where pse__Status_ _c IN: ResourceRequestStatus and pse__Project__c IN: projects]);
HarshHarsh (Salesforce Developers) 
Hi,
Can you paste the start method code?
Somasundaram SubramanianSomasundaram Subramanian
Thanks and pls find below code global class Batch_RollupProjectEstvsActMetrics implements Database.Batchable{ public set setProjectIds; global Batch_RollupProjectEstvsActMetrics(set setProjectIds){this.setProjectIds = setProjectIds;} global Batch_RollupProjectEstvsActMetrics(){} global Database.QueryLocator start(Database.BatchableContext BC){ string query = 'select id,ETC_Hours_Placeholder__c,ETC_Dollar_Placeholder__c,EAC_Hours_Placeholder__c,EAC_Dollar_Placeholder__c from pse__Proj__c '; if(setProjectIds projects){ date M_TDate = date.today();//Today Date date M_SWDate = M_TDate.toStartofWeek();//Start Date of week date M_EWDate = M_SWDate.addDays(6);//End Date of Week set ResourceRequestStatus= new set {'Ready to Staff'}; set TimePeriodType = new set {'Week'}; map> mapProjectRR = new map>(); map> mapProjectActual = new map>(); map mapRR = new map([select Id, pse__Project__c,pse__SOW_Hours__c, pse__Requested_Bill_Rate__c from pse__Resource_Request__c where pse__Status__c IN: ResourceRequestStatus and pse__SOW_Hours__c > 0 and pse__Project__c IN: projects]); map mapActual = new map([select Id,pse__Project__c,pse__Estimated_Hours__c,pse__Scheduled_Bill_Rate__c, pse__Start_Date__c,pse__End_Date__c,pse__Actual_Hours__c,pse__Actual_Billable_Amount__c from pse__Est_Vs_Actuals__c where pse__Time_Period_Type__c IN: TimePeriodType and pse__Project__c IN: projects and ((pse__Start_Date__c >=: M_SWDate and pse__Estimated_Hours__c > 0) and (pse__End_Date__c 0))]); for(pse__Resource_Request__c p: mapRR.values()){ set setTemp = new set(); setTemp.add(p.id); if(mapProjectRR.containsKey(p.pse__Project__c)){ setTemp.addAll(mapProjectRR.get(p.pse__Project__c)); } mapProjectRR.put(p.pse__Project__c,setTemp); } for(pse__Est_Vs_Actuals__c p: mapActual.values()){ set setTemp = new set(); setTemp.add(p.id); if(mapProjectActual.containsKey(p.pse__Project__c)){ setTemp.addAll(mapProjectActual.get(p.pse__Project__c)); } mapProjectActual.put(p.pse__Project__c,setTemp); } for(pse__Proj__c p: projects){ decimal EVA_Est_Cur_Fut_Hours = 0; decimal EVA_Est_Cur_Fut_Rate = 0; decimal EVA_Act_Past_Hours =0; decimal EVA_Act_Past_Rate =0; decimal RR_Est_Hours =0; decimal RR_Est_Rate =0; if(mapProjectActual.containsKey(p.id)){ for(Id EAId: mapProjectActual.get(p.id)){ pse__Est_Vs_Actuals__c EA = mapActual.get(EAId); if(EA.pse__Start_Date__c >= M_SWDate ){ //For Estimated hours = current week's estimated hours + future weeks' estimated hours EVA_Est_Cur_Fut_Hours += EA.pse__Estimated_Hours__c; EVA_Est_Cur_Fut_Rate += (EA.pse__Scheduled_Bill_Rate__c null)? EA.pse__Actual_Hours__c:0; EVA_Act_Past_Rate += (EA.pse__Actual_Hours__c null)? EA.pse__Actual_Billable_Amount__c :0; } } } if(mapProjectRR.containsKey(p.id)){ for(Id rId: mapProjectRR.get(p.id)){ pse__Resource_Request__c r = mapRR.get(rId); RR_Est_Hours += r.pse__SOW_Hours__c; RR_Est_Rate += (r.pse__Requested_Bill_Rate__c