function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jeff BloomerJeff Bloomer 

Invalid Field Error for Data.com Field on Account

Feeling really dumb today, because I can't figure this out.

 

Anyway, all I'm trying to do is return the three-digit prefix from the NAICS Code in the Data.com information on an Account.  When I do so, I get this error:

 

Save error: Invalid field NaicsCode for SObject Account /SR Salesforce - STAGE/src/classes line 50 Force.com save problem AccountUtils.cls

 

I'm not doing anything all that difficult, and I validated that my user profile has the field visible.

 

public static void addThreeDigitNAICS(List<Account> acctList) {

    Id naicsId = null;
    String threeDigit = null;
    List<NAICS_Code__c> naicsCode = new List<NAICS_Code__c>();

    for (Account a: acctList){
        threeDigit = a.NaicsCode.left(3);
        ...
        ...
    }
}

 I have access to view the field in just about everything else.  Am I just hosed?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeff BloomerJeff Bloomer

Here's what I ended up doing for a workaround.  I created a formula field on Account using the LEFT function to get the three-digit code, which I'm then calling in the class.  It seems silly that I had to add a field in Account in order to get this done, but it accomplishes what I need.  Inefficient, but it works.

All Answers

CheyneCheyne

Is NaicsCode a custom field? Maybe you have to write NaicsCode__c?

Jeff BloomerJeff Bloomer

Boy do I wish it was that easy. Because it's a Data.com field, it appears in the list of standard fields for Account, so the field name is NaicsCode. It's really frustrating that I can't share screen shots, because I can even see the field as a suggested choice in Eclipse when I place the dot after my variable.

 

It says: NaicsCode string - Acccount's field

Jeff BloomerJeff Bloomer

Here's what I ended up doing for a workaround.  I created a formula field on Account using the LEFT function to get the three-digit code, which I'm then calling in the class.  It seems silly that I had to add a field in Account in order to get this done, but it accomplishes what I need.  Inefficient, but it works.

This was selected as the best answer