Anonymous Apex querying person accounts behaviour inconsistent from Dev Console

Issue #1409 resolved
John Zhao created an issue

When I try to run an anon apex script where I query for person accounts' contact fields, illuminated cloud gives me an error saying “No such column “[fieldname]__pc” on entity ‘Account’”

However, the soql query works just fine when running in SOQL query editor.

I copied and pasted the exact same code into the salesforce Dev Console anonymous apex editor, and it executed fine without any problems.



List<Account> pas = [
select Id, TIPS_ID__c, TIPS_ID__pc
from Account
where IsPersonAccount = true
and TIPS_ID__c = null
and TIPS_ID__pc != null
limit 10000


Compile failure on line 1, column 21:
select Id, TIPS_ID__c, TIPS_ID__pc
ERROR at Row:2:Column:32
No such column 'TIPS_ID__pc' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

Comments (6)

  1. Scott Wells repo owner

    John, the only transformation that IC performs when it executes anonymous Apex and SOQL queries is namespace substitution. If your module is configured for a connection with a namespace, and you've also configured an "official namespace" for that module, IC will transform <official-namespace> qualifications into <org-namespace> qualifications. My guess is that's not what's happening here, though, as I don't see any namespaces in your query.

    The other possibility is that the user in the connection used by IC doesn't have access to that field. By default IC tries to ensure field access when generating an OST, if it's possible that the user can't access that field when this error is occurring. If that's the case, you'd get this exact error message because it's as if that field doesn't exist from the perspective of the authenticated user.

    Are you potentially using one user in IC and another in Developer Console?

  2. John Zhao reporter

    Hi Scott, my user is Sysadmin and it is the same login in both IC and dev console. In terms of namespace, when I go to IC’s module settings, I don’t see any available namespaces to choose from. They are all fields in the standard account and contact objects so I don’t think namespace is the issue here.

    The weird thing is the query editor in IC works fine, but anon apex doesn’t…

  3. Scott Wells repo owner

    I agree that that's very strange, John. Both of those tools--Anonymous Apex and SOQL Query--perform the exact same transformations on their respective script before asking the server to execute them. Barring a Salesforce API issue, I would expect the same behavior between the two.

    Let's do this...I'd like to see the EXACT API request payload. Please add the following to Help>Debug Log Settings:


    then restart the IDE completely (sorry...this is the one logging change that requires it) and reproduce the issue. Then your idea.log (found using Help>Show Log in Explorer/Finder/Files) will contain the actual SOAP request and response. Note that it will also contain the login details and such as well, so don't post the entire idea.log file...or minimally scrub it of your credentials. If you're not sure which subset to grab, please let me know and I'll be happy to provide the details.

  4. John Zhao reporter

    Hi Scott, unfortunately, I can seem to replicate this issue anymore… Maybe it was restarting the IDE that did the trick? I’m not really sure. But, I guess for now, this issue can be closed as I’m unable to provide the logs that could point to the issue. Thanks for your help in investigation this problem.

  5. Scott Wells repo owner

    Hmmmm...that's really strange. As you suggested, resolving for now, but if you see this behavior again reopen or email me.

  6. Log in to comment