I have 2 Visualforce components inside a main page. Now the issue is that I need to call a @future method from one of them and I think this is not possible. Every time I get an error:

System.LimitException: @future call currently not allowed

This is my future call method:

global class TestHelper {
    @future(callout = true)
    public static void syncTest(String dateStr, List<String> feedIdList) {
        System.debug('do something...' + feedIdList);

This is my Controller:

public class testctr {
    public void test() {
        TestHelper.syncTest('199', new List<String>{'1', '2'});

This works:

<apex:page controller="testctr">
<apex:form >
<apex:pageBlock >
<apex:commandButton action="{!test}" value="test"/>

These don't:


<apex:component controller="testctr">
<apex:commandButton action = "{!test}" value="test"/>

Is there any way I can make a future call possible form a component or I have to redesign altogether?

  • Does it work if you remove the callout=true? – battery.cord Jan 9 '18 at 14:38
  • No it doesn't. Gives same error. – SFDC Dev 27 Jan 9 '18 at 15:34
  • what if you place allowDML="true" in component definition? if you comment callout? does that work? – kurunve Jan 9 '18 at 16:45
  • if the above doesn't work, pass the outer controller's object as an argument to the component – cropredy Jan 9 '18 at 22:06
  • allowDML = "true" worked, thanks @kurunve! Please add as an answer:) – SFDC Dev 27 Jan 10 '18 at 12:44

As suggested by @kurunve I added allowDML="true" in the component definition and that worked. I am adding this as an answer to mark this question solved, as I didn't get response from @kurunve to post his comment as answer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.