15

I've ran into this issue once or twice before. The problem manifests itself as this in the Force.com 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!

  • I my case, I used __Share on object, which doesn't have one. – Andrii Muzychuk Apr 3 '15 at 8:48
  • 1
    Yeah, pain in the ass. Thinks its if you make a syntax error with anything that is a reserved word, something like that anyway. – Phil Hawthorn Apr 3 '15 at 9:29
15

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 Force.com IDE) compare with and try to narrow down the areas to look in, which isn't really any different to what you are doing.

  • Ok so essentially it means you have a syntax error in your code? – anataliocs May 28 '14 at 15:07
  • Is there a way to CATCH "Entity is not org-accessible" error ? – Chirag Mehta Aug 17 '15 at 7:25
0

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.

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.