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
SurekaSureka 

@future method calling repeatedly

Hi All,

 

I have a after insert/update trigger on a custom object from where I am passing a list of the object Ids to the  @future method.

 

In the @future method, I am performing some updates to the same records and updating the records.

 

My @future method is called repeatedly and I am getting this error: "Future method cannot be called from Future method"

 

Any Idea how to overcome this?

 

Thanks

anan

Use a static variable to check if trigger is fired from @future method. In other words create a static variable which you set for example to true in @future method. Then you can check the value in the trigger and stop execution if it is true.

hisrinuhisrinu

Here you have two approaches.

 

1. Change the trigger to before insert, before update

2. Move your logic to class (invoke this class from trigger) and use static variable over there so that you can controller the trigger not to fire on update when you are inserting the records. Don't worry it works fine for the regular updates.