5

I am trying to create a Data Load Tool similar to Data Loader which will upload the data from a CSV file to Salesforce. This tool is built using java and using "Bulk API". While this tool works fine, it is only creating problems when I try to insert null values through CSV.

I checked the "Bulk API Developer Guide" and it is mentioned that "Empty field values are ignored when you update records. To set a field value to null, use a field value of #N/A."

I wanted to know that is there any alternate way in which i can set the field values to "null" without having to set them to "#N/A" in CSV? Something similar to Data Loader, where blank fields are treated as "null" when we enable "Insert Null Values".

5

Since this hasn't been responded to after having been posted for several weeks, it would appear that no one has a timely suggestion for you.

My suggestion would be pre-process your CSV files using a script that scans them for field entries containing blank values and inserts a "#N/A" if it finds one. You could do that separately or as part of some kind of "front end" processing by your Utility Tool. You may have some other way of doing that via Java, but I'd think a simple Bat file or VB Script would do the job for you without requiring much work on your part to create it.

  • Re-reading this, it sounds like the goal is to write a tool in Java which interacts with Bulk API. In which case instead of pre-processing the CSV it should be trivial to replace null with #N/A as the records are being parsed? – Doug B May 10 '13 at 13:49
  • I'd think so too, but since no one responded, I applied the KISS approach. ;) – crmprogdev May 10 '13 at 14:11
  • Thanks for your reply. I think I shall give that a try. For now, it has been ageed to continue using #N/A. But if I am able to do wht is suggested, it would definitely save lot of time. – Shailesh Deshpande May 10 '13 at 15:05
1

Note that you may run into a snag when trying to set a Lookup field to null...

Say you have lookup field RelatedRecord__c and normally you set it by specifying a value for RelatedRecord__r.RelatedRecordExternalID__c. You won't be able to specify null here (Salesforce will throw an error) ... instead, you'll need to explicitly set RelatedRecord__c to null.

-2

So I think I found a solution to this issue. Instead of setting the field to nil or null, try setting it to the string '#N/A'

Empty field values are ignored when you update records. To set a field value to null, use a field value of #N/A.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.