1

I'm trying to use Test.LoadData.

CSV

Name, TEST_field__c
1,test1
2,test2

TestClass

 List<TESTObject__c> a = Test.loadData(TESTObject__c.sObjectType, 'TestData');

When I tried to load this csv from static resource, I caught error like this.

System.StringException: Unknown field: TEST_field__c

Can custom field data load from static resource?

Absolutely same situation

https://codeday.me/jp/qa/20190427/715216.html

1
  • did you remove the space inside: Name, TEST_field__c
    – cropredy
    Commented Nov 21, 2019 at 22:46

1 Answer 1

4

I will just copypaste the answer that I found on the SF Forums for the same problem:

There is an incideous little devil-in-the-details issue here, and it's known as the Byte Order Mark (BOM)(https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding). In short, it's an invisible character that certain programs like Excel include when it encodes CSV content as UTF-8 (even though it's not recommended) and it causes Salesforce's parser to fail.

You can view and change the file encoding of a CSV in programs like VSCode. I did this, changed the encoding to plain UTF-8, reuploaded the static resource and...VIOLA. Things worked

You must log in to answer this question.

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