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
Chris Walters 9Chris Walters 9 

Subtle text formatting issue with Bulk API 2.0 Insert

version 47
I've a tiny upload.csv file written on a Windoze box with Notepad++ , confirmed to be using CRLF containing two whimsical Contacts:

Name,Phone,Email
Bart Simpson,313-555-1212,haveacow@fox.com
Lisa Simpson,543-434-8474,prez@whitehouse.gov

I've crafted a python script for bulk-inserting these two and all works great right up until the very end when my status response says "JobComplete" and numberRecordsFailed': 2 and the response of calling failedResults is:

['"sf__Id","sf__Error",Email,Name,Phone\r', '"","INVALID_FIELD_FOR_INSERT_UPDATE:Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.:Name --","haveacow@fox.com","Bart Simpson","313-555-1212"\r', '"","INVALID_FIELD_FOR_INSERT_UPDATE:Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.:Name --","prez@whitehouse.gov","Lisa Simpson","543-434-8474"\r', '']

Pay close attention to the \r and all the double-quotes -- am I formatting my csv file incorrectly? I do explicitly set contentType:CSV and lineEnding: CRLF  when setting up the job

Any ideas?
Alain CabonAlain Cabon
The line breaks are almost unverifiable in editors (invisible nature of these characters).

The simple solution is to use : dos2unix or unix2dos if you want be sure that the format of the end lines is fixed correctly for the entire file.

Download here:
https://sourceforge.net/projects/dos2unix/
 
Chris Walters 9Chris Walters 9
I used vim to create the file, used 
set fileformat=dos and hard-saved.  I tried once after set fileformat=unix  and was rewarded with a bunch of 
'errorMessage': 'ClientInputError : LineEnding is invalid on user data. Current LineEnding setting is CRLF'}
messages, so I do think I've got the right line breaks. And yet...
Chris Walters 9Chris Walters 9
Oh, but it was a subtle one indeed!--- it complaines about trying to insert to a Contact.Name field , and rightly so because.....
Contact.Name is really a Formula, a concatenation of Contact.firstName and Contact.lastName. And you can't insert into a Formula of course.

Changing my csv file to be:

firstName,lastName,Phone,Email
Bart,Simpson,313-555-1212,haveacow@fox.com
Lisa,Simpson,543-434-8474,prez@whitehouse.gov

did the trick

CASE CLOSED

Chris