Salesforce

From Starfish ETL
Revision as of 20:16, 15 September 2015 by Jkuehlthau (talk | contribs) (→‎Bulk)
Jump to navigation Jump to search

Salesforce Destination

Standard

Input your Username and Password, making sure to append your user's API Token to the end of your password. If you are not using Bulk Mode, be careful to not run too many transactions or you could hit your rolling 24 hour limit. To get your API Token, open your Personal Settings and click Reset My Security Token. (The Salesforce UI changes over time, so you may have to google the current method of getting your API Token.)

Bulk

Check the "Use Bulk Mode" checkbox to use Bulk mode. This creates local csv fils of your changes and uploads the csv files to Salesforce to process in batches. If you are using Bulk Mode and performing updates or upserts, make sure you are matching on a field that is marked a unique identifier from a foreign program, else you will get an error. In Starfish, a unique identifier from a foreign program will display as "string - ExternalID (xyz)" Type.

To insert Bulk attachments, you must have "Use Bulk Mode" checked on the Destination Tab. If "Use Bulk Mode" is checked, then you can use the "@@Bulk Attachments" "table" in your stage. Note that the Bulk API can only handle attachments up to 10MB among other limitations. I have always used the standard API for importing attachments, even if I have to do it over the course of several days. The standard API for attachments seems more stable.

Concurrency: Parallel vs Serial. Parallel is a salesforce API option which tells it to process multiple records at the same time on their side, serial is one at a time. Parallel mode doesn't seem very stable so we recommend using serial mode.

Mapping

Stages

Update

When running an Update Stage in standard mode, you can match on any field. When running a Bulk Update stage, you must match on the ID. So you have to use an xref or lookup the ID and match on the ID field.

Update/Insert

When running an Update/Insert Stage in standard or Bulk mode, you can match on any field.

Field Types

Datetime Fields

You must format datetime values to a specific format for Salesforce to accept them.

Function ScriptedField
  ScriptedField=FormatDate("@@ORG:CREATEDATE@@", "yyyy-MM-ddTHH:mm:ss")
End Function

FAQ

SFBulkPost operation: /job error: System.Net.WebException: The remote server returned an error: (400) Bad Request.

When I received this error, I was matching against a standard text field. You must go into setup and check the "External ID" checkbox for the field you are matching on.

System.Web.Services.Protocols.SoapException: REQUEST_LIMIT_EXCEEDED: TotalRequests Limit exceeded.

When I received this error, I was using the non-bulk API and upserting Contacts one at a time. This caused me to very quickly go over my rolling 24 hour limit. We contacted Salesforce and were able to raise our API limit for 2 weeks. It's best to use the non-bulk API for troubleshooting and then switch to the bulk API for mass imports. To check your API usage, open Setup -> System Overview and look at API Usage.

The Bulk API seems to hang.

When using the Bulk API, Starfish builds a csv file locally which is then uploaded to Salesforce and processed by Salesforce. Salesforce then returns the results of the process. Sometimes, Salesforce never responds - or the response doesn't match what Starfish is expecting. When this happens, Starfish continues to wait for a response. If this occurs, check the results of the data load inside Salesforce by going to Setup -> Monitor -> Jobs -> Bulk Data Load Jobs. Based on the results in Salesforce, you can choose when to Cancel the Job in Starfish and choose what to do as a result.

The Bulk API seems to fail all rows after processing tens of thousands of records.

When using Parallel Concurrency, Salesforce sometimes begins throwing errors due to internal page locking or other exceptions. It is recommended to use the Serial Concurrency setting.

I can't write CreatedDate or CreatedBy.

You can only write to CreatedDate and CreatedBy if you open a case with Salesforce and request that they turn on "Create Audit Fields" for your instance. This will allow you to set the CreatedBy and CraetedDate fields when importing. It will not work when updating records.

How can I see the results of a Bulk Job?

In Salesforce, surf to Setup -> Jobs -> Bulk Data Load Jobs. On this page, you should see a list of your recent bulk jobs. Open the Starfish Job's Destination tab and click the Job Results button on the Salesforce Connector tab. Paste the Job ID into this and Starfish will save and open an Excel file of errors.

invalid cross reference id

This occurrs when you are populating a reference (18) field with an invalid value. For example, if you are inserting into Users and you put an invalid Profile ID into the ProfileId field, you will see this error.