SSIS Salesforce Source
PreviousNext

SSIS Salesforce Source can be used to extract large amount of data from Salesforce.com without any programming. You can use simple Table mode or Query mode with full SOQL query language support (SOQL=Salesforce.com Object Query Language).

Download SSIS PowerPack

Content

Video Tutorial

Step-By-Step

In this tutorial you will learn how to read SalesForce Storage Data using SalesForce Source(In this case its Table and Query Mode).
  1. Firstly, You need to Download and Install SSIS ZappySys PowerPack.
  2. Once you finished first step, Open Visual Studio and Create New SSIS Package Project.
  3. Now, Drag and Drop SSIS Data Flow Task from SSIS Toolbox.
    SSIS Data Flow Task - Drag and Drop
  4. Double click on the Data Flow task to see Data Flow designer surface.
  5. Here, In Visual Studio, drag and drop the ZS SalesForce Source in the design surface.
    SSIS SalesForce Source - Drag and Drop
  6. Now, we need SalesForce Connection. Click here to create SalesForce Connection.

How to read data from SalesForce table using SalesForce Source(Query Mode).

  1. Here, we are getting data using Query Mode with Dynamic expression value.
  2. Lets, create a Variable with correct DataType and Value, use following image.
    SSIS SalesForce Source - Create Variable
  3. Double click on SalesForce Source to configure it.
  4. Select connection we have created before, set AccessMode to Query, Enter Following Query and Replace Variables if differ name. Click here for more SOQL Query Examples.
    SELECT Id, Name, BillingCountry, NumberOfEmployees
    FROM Account
    WHERE Name LIKE '{{User::Name}}' 
    and BillingCountry = '{{User::BillingCountry}}'
    and NumberOfEmployees >= {{User::NumberOfEmployees}}
    
    SSIS Salesforce Source - Query mode (query data using SOQL language)
  5. Click on Preview button to see Data Preview.
  6. Click on OK button to save configure setting UI.
  7. From the SSIS toolbox drag and drop Trash Destination on the data flow designer surface.
    SSIS Trash Destination - Drag and Drop
  8. Now single click on the SalesForce Source, once you see blue arrow from source ... connect it to Trash Destination.
  9. Double click on ZS Trash Destination to Configure it.
    SSIS Trash Destination - Configure
  10. Click on OK button to save Trash Destination configure setting UI.
  11. Thats all, just run or execute your package and see data.
    SSIS SalesForce Source Query Mode - Execute

How to read data from SalesForce table using SalesForce Source(Table Mode).

  1. Double click on SalesForce Source to configure it.
  2. Select connection we have created before, set AccessMode to Table and Select Tables from table dropdown list.
    SSIS Salesforce Source - Table mode (get data from object)
  3. Click on Preview button to see Data Preview.
  4. Click on OK button to save configure setting UI.
  5. From the SSIS toolbox drag and drop Trash Destination on the data flow designer surface.
    SSIS Trash Destination - Drag and Drop
  6. Now single click on the SalesForce Source, once you see blue arrow from source ... connect it to Trash Destination.
  7. Double click on ZS Trash Destination to Configure it.
    SSIS Trash Destination - Configure
  8. Click on OK button to save Trash Destination configure setting UI.
  9. Thats all, just run or execute your package and see data.
    SSIS SalesForce Source Query Table - Execute

Properties

Property Name Description
AccessMode AccessMode for Salesforce Data

Available Options (Use numeric value listed in bracket if you have to define expression on this property (for dynamic behavior).

Option Description
Table [0] Table
Query [1] Query
LoggingMode LoggingMode determines how much information is logged during Package Execution. Set Logging mode to Debugging for maximum log.

Available Options (Use numeric value listed in bracket if you have to define expression on this property (for dynamic behavior).

Option Description
Normal [0] Normal
Medium [1] Medium
Detailed [2] Detailed
Debugging [3] Debugging
PrefixTimestamp When you enable this property it will prefix timestamp before Log messages.
TableName Source object name from where you want to read data. This option only used when AccessMode=Table
BatchSize How many rows you want to fetch in each request.
Query Crm query to read data. This option only used when AccessMode=Query
MaxRows Maximum number of rows to fetch from source. 0=Unlimited
IncludeDeleted Set this to true if you want to read deleted records
InputDateTimeConversionMode Specifies how to convert input date/time string / variable values (For query mode only)

Available Options (Use numeric value listed in bracket if you have to define expression on this property (for dynamic behavior).

Option Description
None [0] Default
UtcToLocal [1] Output As Local Time
LocalToUtc [2] Output As UTC Time
FormatISO [3] Output As ISO format
OutputDateTimeConversionMode Specifies how to convert output date/time coming from source (e.g. If CRM is sending date in UTC you may automatically convert it to Local DateTime using this option)

Available Options (Use numeric value listed in bracket if you have to define expression on this property (for dynamic behavior).

Option Description
None [0] Default
UtcToLocal [1] Output As Local Time
LocalToUtc [2] Output As UTC Time
FormatISO [3] Output As ISO format

SOQL Query Examples

SOQL Query - Basic Query

This example shows how to write simple SOQL query (Salesforce Object Query Language). It uses WHERE clause, ORDER BY and LIMIT clause. Using limit clause it will return only 10 records at maximum.

SOQL is similar to database SQL query language but much simpler and many features you use in database query may not be supported in SOQL (Such as JOIN clause not supported)

For more information about SOQL query syntax check below links :
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm
SELECT Id, LastName, FirstName 
FROM Contact
Where LastName!='Smith'
ORDER BY LastName, FirstName
LIMIT 10

SOQL Query - Parent fields (Child-to-Parent / Many-to-One)

This example shows how to get field value from related parent object using dot operator.

For more information about relationships query check this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_using.htm
SELECT Id,FirstName, LastName, Account.Name FROM Contact

SOQL Query - Child records (Parent-to-Child / One-to-Many)

This example shows how to get child records for selected parent records (e.g. All contacts for specified accounts).

For more information about relationships query check this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_using.htm
SELECT Account.Id,Account.Name
    , (SELECT Contact.FirstName, Contact.LastName, Contact.Email FROM Account.Contacts) 
FROM Account

SOQL Query - Child Query with Order By and LIMIT

This example shows how to use child query and limit number or child records for each parent row.

SELECT Name, 
    (SELECT FirstName, LastName FROM Contacts ORDER BY CreatedDate LIMIT 5) 
FROM Account
Where Name='ZappySys'

SOQL Query - Object and field alias

This example shows how to alias Table name or field name in SOQL queries. SOQL has very limited support for alias. You can alias Table name in any query but field alias is only allowed in Aggregation query only (Query with at least one aggregation function).

For more information about Alias in SOQL query check this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_alias.htm?search_text=Alias
For more information about Alias in Aggregation query check this link: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_groupby_alias.htm?search_text=Alias
SELECT c.Id, c.LastName, a.Name 
FROM Contact c,c.Account a
LIMIT 10

SOQL Query - GROUP BY / Aggregate function

This example shows how to use GROUP BY clause along with optional HAVING clause. When you use Aggregate function in SQL Query you can also use alias for field (This is the only time alias can be used). Child query cannot be used when Aggregate functions are used. Refer help file to learn more about other consideration.

For more information about GRPOUP BY check this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_groupby.htm
SELECT LeadSource, COUNT(Name) Cnt
FROM Lead
GROUP BY LeadSource
HAVING COUNT(Name) > 100

SOQL Query with DateTime / Use of variable

This example shows how to use variable placeholders anywhere in query to make it dynamic. You can use inbuilt Date Literals (e.g. TODAY, YESTERDAY, LAST_N_DAYS:365). By default when variable with DateTime type is used then its automatically converted to UTC datetime format before sending query to server. If you want to query by UTC Date only (without time portion from variable) then use TO_UTC_DATE rather than TO_UTC_DATETIME format specifier (e.g. SELECT Id, FirstName FROM Contact WHERE CreatedDate < {{System::ContainerStartTime,TO_UTC_DATE}} ). To convert UTC date variable to Local Date use TO_LOCAL_DATE or TO_LOCAL_DATETIME

For more information about query datetime field check this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm?search_text=date
For more information about variable placeholder usage check this link : https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-format-specifiers.htm
SELECT Id, LastName, FirstName, Email, Account.Name 
FROM Contact
Where LastModifiedDate < {{System::ContainerStartTime,TO_UTC_DATETIME}} AND CreatedDate < YESTERDAY
LIMIT 10

SOQL Query - IN clause with Subquery

This example shows how to use sub query result for IN clause.
For more information check this link:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_comparisonoperators.htm
SELECT Id, Name 
FROM Account
WHERE Id IN
  (
    SELECT AccountId
    FROM Contact
    WHERE LastName LIKE 'a%'
  )
  AND Id IN
  (
    SELECT AccountId
    FROM Opportunity
    WHERE isClosed = false
  )

SOQL Query - Use of special characters (i.e Escape sequence)

This example shows how to use reserved special characters inside string literals using escape sequence. Anytime you have reserved character in string then use slash (\) in front of character e.g. Sam's Farm would be Sam\'s Farm.
For more information check below links:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_quotedstringescapes.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_reservedcharacters.htm
SELECT Id FROM Account WHERE Name = 'Sam\'s Farm'

Setting UI

SSIS SlesForce Source - Setting UI
SSIS SlesForce Source - Setting UI
SSIS SlesForce Source - Setting UI
SSIS SlesForce Source - Setting UI

See Also

References

Articles / Tutorials

Click here to see all articles for [SSIS Salesforce Source] category
SSIS PowerPack v2.9.5 released (Maintenance Release)

SSIS PowerPack v2.9.5 released (Maintenance Release)

What’s New In this release we focused on fixing some bugs with Dynamics CRM Source , Dynamics CRM Destination and Reporting Services Task. Version 2.9.6.10621 [Jun 24, 2019] New Features/Improvements NEW: Excel Source – Add option to read from any sheet by number rather than hard coded table name (e.g. $4$ , $5$ … ) Bug fixes […]


How to export data from Salesforce to SQL Server using SSIS

How to export data from Salesforce to SQL Server using SSIS

Introduction Salesforce is a popular CRM tool which lets you manage your sales, contacts, products and other useful things. In this tutorial, you will learn how to export data from Salesforce to SQL Server using SSIS (part of SQL Server) and ZappySys PowerPack. In this article, we will extract Salesforce contacts and import them into a […]



Copyrights reserved. ZappySys LLC.