[SalesForce] Batch jobs for calling future methods

I want to know if we can use batch jobs to call future methods (I want to insert users and that triggers a future method that assigns an Id to the user and manipulates a couple of fields) so I want to know if it is viable or not.

Best Answer

I have found a way to call a future method from a scheduled class but not batch class.It might help you : -

global class Scheduledbacthfuture Implements Schedulable{

    public Interface IScheduleDispached{
        void execute(SchedulableContext sc);
    }

    global void execute(SchedulableContext sc){
        Type targetType = Type.forName('{HANDLERNAME');
        if(targetType != null){
            IScheduleDispached obj = (IScheduleDispached)targetType.newInstance();
            obj.execute(sc);
        }
    }


}

public class {HANDLERNAME} implements Scheduledbacthfuture.IScheduleDispached {

  public void execute(SchedulableContext sc)
    {
        //Call your Future Method Here

    } 

}