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
Streepie24Streepie24 

Future method cannot be called from a future method: sluiten(LIST:Id)

Hi,

 

I just changed my update code from a trigger to a future class to avoid governor limits.

The trigger calls the Future Class.

Now i am getting the following error: Future method cannot be called from a future method: sluiten(LIST:Id)

I don't call a future method from a future method ... or am i ??

The trigger is not FUTURE....!?

 

TRIGGER:

trigger Sluiten_AF_Taken on Achterstallige_factuur__c (before update) { //haal Id van SYSTEM op User sys = [SELECT Id FROM User WHERE Alias =: 'SYSTE']; //Hulplijst List<Id> afact=new List<Id>(); for(Achterstallige_factuur__c af: Trigger.new){ if(af.status__c == 'Afgehandeld'){ afact.add(af.Id); } } Sluiten_AF_Taken_Handler.Sluiten(afact); }

 

FUTURE CLASS:

 

public class Sluiten_AF_Taken_Handler{ //Trigger Sluiten_AF_Taken kan niet worden gebruikt voor de bulkupdate // vandaar dat we vanuit de trigger naar deze @Future Class springen // alwaar we wel bulkupdates kunnen uitvoeren ! @Future(callout=false) public static void sluiten(List<Id> AFIDS){ //haal Id van SYSTEM op User sys = [SELECT Id FROM User WHERE Alias =: 'SYSTE']; //Hulplijst List<Task> toUpdate = new List<Task>(); List<Task> t=new List<Task>([SELECT Id, WhatId FROM Task WHERE CreatedById =: sys.Id and status != 'Afgesloten' ]); for(Id aft: AFIDS){ for(Task tk: t){ if(tk.WhatId==aft){ tk.status = 'Afgesloten'; tk.IsReminderSet = false; toUpdate.add(tk); } } } update toUpdate; } }

 

Best Answer chosen by Admin (Salesforce Developers) 
David VPDavid VP
Most likely you have something like another trigger or a workflow field update that's being fired. That could cause other @future methods or perhaps even this one to be called again.