0

I'm using the npm package node-salesforce@0.8.0 to write a custom integration with Salesforce.

The package works fine most of the time, the problem arises when a user selects maps our contact data to incompatible Salesforce custom fields at the contact or lead level.

For example, if one of our fields is 600 characters long, but Salesforce's custom field max length is 100 characters; the moment the user decides to import this record to Salesforce as a contact or lead, the API throws a fatal error and the contact/lead is not created.

In order to solve this issue, I've come up with 2 solutions:

  1. Create a contact with just First Name, Last Name and AccountId and then update the newly created contact with our data (this is fine, the problem is that it uses 2 API Calls)

  2. Research if Salesforce API supports an "INSERT IGNORE" kind of query, that as long as FirstName, LastName and AccountId are present, the contact is still created despite some custom fields being invalid.

I'm fine with option #1, but I'd really like to know if it's possible to accomplish #2. Or in other words:

Is there a way to still create a contact even if some custom fields fail?

5

Inserts are all or nothing, but if the only issue has to do with field lengths, you could use the AllowFieldTruncationHeader, which allows the field to store just up to the maximum length instead of providing an error. Of course, this means that some data will be lost, but if it's preferable to a total failure, this might be an acceptable alternative. Consider allowing the user to choose if they want to allow the truncation to happen.

  • The first paragraph of that document seems conflicting. Nice info though – Eric Jul 9 '17 at 2:17
  • 1
    @Eric I'm going to go complain to the documentation team... again. This seems to be a fairly frequent occurrence these days. – sfdcfox Jul 9 '17 at 3:53
2

To strictly answer your question: No. Either an insert succeeds or it does not.

I don't know which features the npm package covers but describe (Apex, also available via API) information would be able to tell you if a custom field exists, what type it is, properties (length) it has, etc.

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.