Fix for Formula Expression is required on the action attributes error

Sometimes Salesforce throws error’s messages which might to confound. It’s not depend on your seniority level as developer. But it’s not your fault, it’s just a very misleading error. Today I got the following error when was working with VisualForce page:

Formula Expression is required on the action attributes

Hmm, I checked each expression, each button, a whole markup on the page. But I found nothing. The markup was good. I double check the markup. And nothing was found again. So, I went deeper to Google and finally I found the answer. It was incredibly easy to find and very stupid from my side.

So, there is an answer. You know that when you construct PageReference you have to do it in the following manner

[java] PageReference nextPage = new PageReference(‘/apex/MyCoolVisualForcePage’); [/java]

But I made stupidly mistake in such simple place

[java] PageReference nextPage = new PageReference(‘MyCoolVisualForcePage’); [/java]

It was fine for Salesforce on compilation level. But in runtime it crashed. Also you will find this error around if write in the such manner

[java] PageReference nextPage = new PageReference(‘apex/MyCoolVisualForcePage’); [/java]

So, leading backslash is required in PageReference constructor and if you miss it Salesforce will return really misleading error.

[apex][errors][exceptions][salesforce errors][visualforce]