Formula Expression is required on the action attributes error

Formula Expression is required on the action attributes error occurs when pagereference('/apex/pageName') doesn't have backslash in front of apex.

Correct: pagereference('/apex/sample1');

Incorrect: pagereference('apex/sample1');

in incorrect, backslash ('/') is missing in front of apex.

Cheers!!!

4 comments:

  1. Hey! thanks a lot for that information it is truly helpful

    ReplyDelete
  2. This error will also occur if you try to return something from the action attribute call of an apex:commandButton. For instance:

    in page:
    <apex:commandButton action="{!getData}" value="Create Sandbox Data"/>

    in controller:
    public String getData() {
    String result;
    Boolean success = true;

    // create some data

    return result = success ? 'Data created with success.' : 'Problems were encountered creating sandbox data. Refer to logs for details.';
    }

    ReplyDelete
  3. I spent an hour to detect this one. Thanks a ton! :)

    ReplyDelete