Tuesday, October 9, 2012

Salesforce Save error: Entity is not org-accessible

The following line of Apex attempting to pull the more recent ApexPages Message produced an error I haven't encountered before. What made it particularly confusing was the lack of a line reference in the error.

Message mostRecentMessage = ApexPages.getMessages().get(ApexPages.getMessages().size() - 1);
Save error: Entity is not org-accessible

Changing is as follows resolved the issue (Note the ApexPages.):

ApexPages.Message mostRecentMessage = ApexPages.getMessages().get(ApexPages.getMessages().size()-1);

If you encounter the same error check the most recently changed lines for incorrect class references, such as a spelling mistake, a missing classname or __c suffix.