0

I am trying to call a future method from my scheduled apex but it is giving this error message

Scheduled class

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);
    }
}
}

Handler

 public class HANDLERNAME implements Scheduledbacthfuture.IScheduleDispached           
 {

  public void execute(SchedulableContext sc)
   {
    //Call your Future Method Here
   List<User> newusers = [Select Id,CFS_Activation_Date__c from user where (Profile.Name='CTCT Solution Provider (Login Based)'OR Profile.Name='CTCT Solution Provider (Named)')AND lmscons__Cornerstone_ID__c=NULL AND lmscons__CFS_Status__c='Not CFS user']; 
    if(newusers.size()>0)
    System.debug(newusers.size()+' new users found will give them license in a sometime');

   if(newusers.size()>0)
   {
    UserHandler.convertListToSet(newusers);
  // lmscons.ConsumerUserWebservice.CreateConsumerUsers(newusers, false); 
   }

 } 

 }

FATAL_ERROR System.CalloutException: Callout from scheduled Apex not supported.

5
  • Please share your code.
    – Samir
    Commented May 2, 2017 at 12:11
  • UserHandler.convertListToSet(newusers); calls a class which calls a future method with @future(callout=true) tag
    – Ishan
    Commented May 2, 2017 at 12:15
  • Just simply remove the @future annotation and it will work. As schedulable execution is of Async nature, it can make the callout in the same execution without any future annotation. Commented May 2, 2017 at 12:19
  • I am using this signature currently @future(callout=true) I think I would try it once without this
    – Ishan
    Commented May 2, 2017 at 12:20
  • 3
    See e.g. salesforceravisharma.blogspot.ie/2016/04/….
    – Keith C
    Commented May 2, 2017 at 12:43

0

Browse other questions tagged .