SFDC wants you to send ID's because it wants to re-query back out the data because an @future
can fire anytime after it is called, the issue is that items in your List<Employees__>
can change, so by re querying out your List you will ensure that you have the most up to date values for your list. Todd is correct but I wanted to explain it a little bit more
What you could do is from the start build a `Map or convert it
List<Employees__c> employeesToUpdate = new List<Employees__c>();
Map<Id, Employees__c> employeeMap = new Map<Id, Employees__c>(employeesToUpdate);
Then call your method.. Also by having that handler method at the top you will be able reuse the method for other @future calls and it will also ensure that you call it properly and only once
EmployeeBenefitSummaries.requestFutureCall(employeeMap.keySet(), FUTURE_REQUEST_EMPLOYEE_SUM )
public class EmployeeBenefitSummaries
{
private static final String FUTURE_REQUEST_EMPLOYEE_SUM;
private static Boolean employeeSumRequestMade = false;
public static void requestFutureCall(Set<ID> employeeIds, String actionType)
{
if(!System.isFuture() && !System.isBatch() && !System.isScheduled())
{
if(actionType == FUTURE_REQUEST_EMPLOYEE_SUM && !employeeSumRequestMade)
{
employeeSumRequestMade = true;
groupSummaryFuture(employeeIds);
}
}
}
@future
public static void groupSummaryFuture(Set<ID> employeeIds)
{
buildGroupSummaries(employeeIds);
}
private static void buildGroupSummaries(Set<ID> employeeIds)
{
//Requery using your employeeIds
//Now you can buildGroupSummaries without having to go through a future also, all you have to do is pass it a set of employee ids
//Do your logic
}
}