Find your content:

Search form

You are here

Efficient way to find error causing "Save Error: Entity is not org-accessible"


I've ran into this issue once or twice before. The problem manifests itself as this in the IDE:

enter image description here

The way I found the issue was by commenting out large swathes of code, and then saving the class to the server again until I narrow it down to the right section. This is quite time consuming.

The actual issue in the code was this, where I'm referencing an object that isn't in the scope of the method:

enter image description here

Obvious once you spot it, I would have expected it to give me an error on the line saying "Save error: Method does not exist or incorrect signature: invoices.getSObject(String)" but it doesn't. Interestingly, if I create another dummy line (below), which you would think would behave the same I do get the correct error:

SObject test = instanceoutofscope.getSObject( 'c2g__Account__r' );

Does anyone know a) the specific conditions in which this error occurs (it seems unpredictable to me), and b) of a more efficient way of detecting it?

Thanks for reading!

Attribution to: Phil Hawthorn

Possible Suggestion/Solution #1

According to the Apex developer's guide:

If the expression ends with a set of parentheses (for example, name1.name2.[...].nameM.nameN()), the Apex parser evaluates the expression as follows:

  1. The parser first assumes that name1 is a local variable with name2 - nameM as field references, and nameN as a method invocation.
  2. If the first assumption does not hold true:

    • If the expression contains only two identifiers (name1.name2()), the parser then assumes that name1 is a class name and name2 is a method invocation.

    • If the expression contains more than two identifiers, the parser then assumes that name1 is a class name, name2 is a static variable name with name3 - nameM as field references, and nameN is a method invocation.

  3. If the second assumption does not hold true, the parser then assumes that name1 is a namespace name, name2 is a class name, name3 is a static variable name, name4 - nameM are field references, and nameN is a method invocation.
  4. If the third assumption does not hold true, the parser reports an error.

In your case the parser has made it to point 4, but hasn't reported a particularly helpful error. It seems likely that the assumption is that invoice is an sobject or class, and that getSObject() is a static method on this sobject/class. Rather than tell you that this sobject/class doesn't exist, it falls back on the assumption that this must be something that just happens not to be visible to your org configuration or license. I think that in the majority of cases the errors reported in this situation are likely to be unhelpful as the parser fundamentally can't determine what you are trying to do, so it has a one size fits all message.

The first few times this happened to me it was with sobject names (Quote was one) so I assumed it that was related to the use of a real sobject name, but I've also had it happen where I've missed out the namespace for a system class (e.g. Action rather than ApexPages.Action).

The biggest problem when I've hit this is that a lot of the time the error is reported as 'line 1 column 8' or is missing completely. If that is the case I just go back over my recent changes (using the IDE) compare with and try to narrow down the areas to look in, which isn't really any different to what you are doing.

Attribution to: Bob Buzzard

Possible Suggestion/Solution #2

I got this error after someone deleted an AppExchange package and a custom object in that package was referred to in a Class written in house.

Attribution to: Joseph Armitage
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content