5

I have seen a similar question asked/answered in multiple places. The gist of the answer is to rely on SOQL Polymorphism. But most examples don't start with with the Account Object, which as far as I can tell has an AccountNumber as a native property on the standard objects. Why is it that a property on a standard object isn't available to the SOQL - am i miss reading the documentation? I did try the Polymoric query which yielded an error:

MALFORMED_QUERY: SOQL TYPEOF expressions are not supported in this organization

I suspect I can get around this by enabling the feature or waiting for a GA release. However that doesn't address the root cause of the problem, as someone new to SF (I am playing around with the JSForce wrapper API), I would like to know both why I am getting this exception on this object, and then some strategies to overcome the exception, and how those strategies work.

Here is my code - per the request (jsforce on NodeJs with ES6 Harmony).

const co = require('co')
    , _ = require('lodash')
    , jsforce = require('jsforce')
    , jsforceConn = new jsforce.Connection()

const accountQuery = '\
        SELECT  \
            AccountNumber \
            , name \
            , ownerId \
            , Client__c \
            , Owner.Name \
            , Owner.Email  \
        FROM Account ' ;

const accounts = function*(userName, pwd) {

    let connection = yield jsforceConn.login(userName, pwd)
    let results = yield jsforceConn.query(accountQuery)
    let firstTenResults = _.first(results.records, 5)
    console.log(JSON.stringify(firstTenResults, null, 4));
    connection.logout() 
}
3
  • Please post the code that gives you this error. Commented Oct 17, 2014 at 16:01
  • The error message refers to the AccountNumber field, but you don't have that field listed in your code. Is this accurate? Commented Oct 18, 2014 at 2:35
  • nope code isn't accurate, I forgot I had removed it to get my example over to another dev to start to poke at. WIll fix
    – akaphenom
    Commented Oct 20, 2014 at 10:37

2 Answers 2

8

If the field is set to Hidden via field level security for the current user profile (if you're an admin fields can still be hidden) you will receive the above error.

If the organization is using Person Accounts and you are accessing a PersonAccount record then this field may not be available for the person account record type.

1
  • 1
    THx. How do I determine whether the field is set to Hidden OR whether I am using Person Accounts? I don't see anything indicative of either on the "Account Fields" page - should I be looking elsewhere?
    – akaphenom
    Commented Oct 17, 2014 at 15:08
5

To check field level security, navigate to Customize>Account>Fields then click on Account Number. Click the button "Set Field-level Security". You'll see all of your profiles listed and which profiles have access to the field. By default, Account Number is hidden via FLS. You can also check on field accessibility from a profile. In any profile, type "Account" in the search box and open the Account object. Review each field to see if the profile has edit and read access.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .