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
Vinay K 39Vinay K 39 

I need to use a method which has future call, of the manage package which is in the Controller of the VF page which is invoked by a custom button. When i click on the button it gives "@future call currently not allowed"

Khan AnasKhan Anas (Salesforce Developers) 
Hi Vinay,

Greetings to you!

There is no issue in calling a future method from a controller class. If you are calling it from a getMethodName or setMethodName or constructor then you will face this issue. To avoid the above exception, please take the following precautions:

1. Methods with the future annotation cannot be used in Visualforce controllers in either getMethodName or setMethodName methods, nor in the constructor.

2. The getContent and getContentAsPDFPageReference methods cannot be used in methods with future annotation.

3. You cannot call a method annotated with the future from a method that also has the future annotation. Nor can you call a trigger from an annotated method that calls another annotated method.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_future.htm

Note: From the get method if you want to execute the asynchronous logic you can call batch apex.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas