SlideShare a Scribd company logo
Scripted Data Loads with
Salesforce Data Loader and ANT
​ Scott Geosits
​ Salesforce.com Architect, Varsity Brands Inc.
​ sjgeosits@herffjones.com
​ @ScottGeosits
​ 
Scott Geosits
Salesforce.com Architect
Varsity Brands, Inc.
Varsity Brands
Varsity Brands
Varsity Brands
Varsity Brands
Agenda
​  Why Scripted Data Loads?
​  Tools – Salesforce Data Loader and ANT
​  Setting Things Up
​  Creating And Running Scripts
​  Use Cases
​  Summary
Agenda
Why Scripted Data Loads?
Why Scripted Data Loads?
Why Scripted Data Loads?
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
SANDBOX REFRESH
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
DATA IN SYNC
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
SANDBOX REFRESH
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
DATA IN SYNC
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
Why Scripted Data Loads?
Full Copy Sandbox
Sandbox
Sandbox
Sandbox
Sandbox
SANDBOX REFRESH
data jenga
Why Scripted Data Loads?
Why Scripted Data Loads?
​ There HAS to be a better way!
​ Predictable and Repeatable data sets
​ Easy re-load of data after sandbox refreshes
•  You SHOULD be refreshing from production OFTEN – after every prod release at a minimum
•  git versioning + scripted data loads means you are productive much sooner after a refresh
​ CI for Selenium / Cucumber style testing in addition to Apex Unit Tests
​ Much better handling of object relationships
•  All but most simple data models have relationships
•  Data loader client requires you to manipulate CSV files to support relationships
•  External ID with UPSERT is how we load data with relationships
Benefits of Scripted Data
Great. So how do we do this?
Tools
​ Salesforce-provided utility for exporting and importing data from a Salesforce org or sandbox
​ CSV file format
​ Available from within Salesforce
​ Save mapping files for repeated operations
​ Load up to 5,000,000 records
​ Run from desktop or command line
Salesforce Data Loader
​ Open source scripting tool
​ Part of Apache project – https://ant.apache.org
​ Define build steps via set of XML target definitions (build file)
​ Supports external build tasks, dependency chains
​ Like make but a hundred thousand times better
​ We will use this to run data loader by making calls to the data loader’s JAR file
Apache ANT
Scripted Data Loads with Salesforce DataLoader and ANT
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
ANT build.xml file
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
Executable utilities
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
SDL mapping files
Pre-built CSV data files
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
Supporting Java JAR files
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
Credentials for SFDC orgs
​ Everything we talk about here is in a github repo for you to experiment with
​ Use consistent structure across projects
github
Sample import / export
scripts
Setup
Salesforce Object Considerations
​ Salesforce record IDs do not match between production and sandboxes
•  Well, not exactly: full copy sandbox IDs match, but we are not typically data loading those
​ External ID is needed to preserve object relationships
​ Our convention will be to create a field called Load_ID__c on all of our objects.
•  Text field with length = 18
•  External ID = true
Setting Up Objects
​ Why do we need to do this? Let’s look at a simple example
​ We have an org that has two accounts
•  ABC Computers – Salesforce ID = 001F000000yHO3ZIAW
•  XYZ Consulting – Salesforce ID = 001F000000yHO3ZIAX
​ Each of these accounts has two contacts:
•  John Jones (ABC Computers) – Salesforce ID = 003a000000xJP2QIAW
•  Jane Peters (ABC Computers) – Salesforce ID = 003a000000xJP3QIAW
•  Jim Smith (XYZ Consulting) – Salesforce ID = 003a000000xJP4QIAW
•  Maria Brown (XYZ Consulting) – Salesforce ID = 003a000000xJP5QIAW
Load ID
Setting Up Objects
​ If we do a field-by-field export of both objects, we end up with the following two files:
Load ID
Setting Up Objects
​ Now if we import these into a sandbox, they will import with different Salesforce IDs:
•  ABC Computers – Salesforce ID = 001g000000yCW4xIAN
•  XYZ Consulting – Salesforce ID = 001g000000yCW4yIAN
​ Looking back at our original records, we see we have a problem as the IDs do not match so we
won’t be able to match the contact records up correctly:
•  ABC Computers – Salesforce ID = 001F000000yHO3ZIAW
•  XYZ Consulting – Salesforce ID = 001F000000yHO3ZIAX
​ Using desktop Data Loader, here’s where you would go in by hand and switch all of the Account
values in the Contact CSV file to match the new IDs.
Load ID
Setting Up Objects
​ If we use external IDs, however, we can upsert on those external IDs
​ Similar to loading a contact list by email address.
​ Email address is not a primary key in Salesforce but set up as external ID and upsert can match on
it.
​ We will steal borrow this pattern and use it to our advantage.
Load ID
Setting Up Objects
​ When we export, we put the Salesforce ID into a field called Load_ID__c in the CSV and end up
with the following two files:
Load ID
Setting Up Objects
​ Now when we import, we tell the data loader to upsert that record into the database using the
Load_ID__c external ID, and we get:
•  ABC Computers – Salesforce ID = 001g000000yCW4xIAN, Load_ID__c = 001F000000yHO3ZIAW
•  XYZ Consulting – Salesforce ID = 001g000000yCW4yIAN, Load_ID__c = 001F000000yHO3ZIAX
​ Comparing against our originals, the Salesforce IDs are different but we’ve preserved the ID from
the source org in our Load ID field:
•  ABC Computers – Salesforce ID = 001F000000yHO3ZIAW
•  XYZ Consulting – Salesforce ID = 001F000000yHO3ZIAX
Load ID
Setting Up Objects
​ We also tell it when establishing the relationships to do so using the Load ID external ID and NOT
the record primary key Salesforce ID.
​ We then get the record inserted with the correct relationship established to the new account
record:
•  Contact John Jones
•  Salesforce ID = 003J000000xZD7GIAW
•  Load ID = 003a000000xJP2QIAW
•  Account = 001g000000yCW4xIAN
​ Note that once the upsert occurs the record is in the target system with the NEW account
Salesforce ID, not the actual Load ID from the old system.
Load ID
Setting Up Objects
Data Loader Mapping Files
​ Define mapping of fieldnames from CSV to Salesforce object and vice versa
​ Text file containing source field name, equals sign, destination field name
•  Must use Salesforce API Field Name, not Label
•  Keep things simple! Use Salesforce API fieldnames for CSV column names.
​ Need to create one mapping file for export and another one for import
•  Naming conventions used by ANT build script:
•  Export file: {Salesforce object API Name}ExportMap.sdl - ex. Candidate__cExportMap.sdl
•  Import file: {Salesforce object API Name}ImportMap.sdl - ex. Candidate__cImportMap.sdl
​ Export mappings have Salesforce field name on left, CSV column name on right
Export Files
SDL Mapping Files
​ Id=Load_ID__c
​ Candidate__c=Candidate__c
​ Position__c=Position__c
​ Stage__c=Stage__c
​ Status__c=Status__c
Export Example
SDL Mapping Files
​ Special notation for relationship fields
​ Need to specify that when a record is imported, it links the object to the related object (which
must already be in the database) via the related object’s Load_ID__c field.
​ We do this with the __r: notation:
•  Candidate__c=Candidate__r:Load_ID__c
Import Files
SDL Mapping Files
​ Special notation for relationship fields
​ Need to specify that when a record is imported, it links the object to the related object (which
must already be in the database) via the related object’s Load_ID__c field.
​ We do this with the __r: notation:
•  Candidate__c=Candidate__r:Load_ID__c
Import Files
SDL Mapping Files
​ Special notation for relationship fields
​ Need to specify that when a record is imported, it links the object to the related object (which
must already be in the database) via the related object’s Load_ID__c field.
​ We do this with the __r: notation:
•  Candidate__c=Candidate__r:Load_ID__c
​ This tells data loader to establish the relationship to the Candidate__c object by matching the
value in the CSV file (Candidate__c) to the Candidate__c record with a matching Load_ID__c
value.
Import Files
SDL Mapping Files
​ Load_ID__c=Load_ID__c
​ Candidate__c=Candidate__r:Load_ID__c
​ Position__c=Position__r:Load_ID__c
​ Stage__c=Stage__c
​ Status__c=Status__c
Import Example
SDL Mapping Files
​ Load_ID__c=Load_ID__c
​ Candidate__c=Candidate__r:Load_ID__c
​ Position__c=Position__r:Load_ID__c
​ Stage__c=Stage__c
​ Status__c=Status__c
Import Example
SDL Mapping Files
ANT Property Files
​ Store Salesforce authentication credentials
•  Username
•  Encrypted password
•  Org server and name
•  Salesforce server
​ Each environment gets one
​ Do NOT version these in git
Setting Up ANT Property Files
​ Must encrypt password using Data Loader encryption utility
•  Encryption utility found under bin/ in Data Loader install directory
•  Also available under bin/ in my github repository
•  Encryption key needed – seed value for hash generator
•  There is one called dataloaderencryptionkey.txt under datascripts/ directory – feel free to modify
•  If you rename, you must rename in template files under datascripts/ as well
​ Encrypt password + security token
Creating Encrypted Passwords
​ Copy result to your properties file
​ One time operation, until your password or security token is modified
Creating Encrypted Passwords
./encrypt.sh –e {password + securitytoken} ../datascripts/dataloader_encryption_key.txt
​ orgname=fullcopy
​ sf.username=myuser@myorg.com
​ sf.passwordencrypted=640b322f24f318d8c2a2fdeb0cdbdd10e3727e16a5a7d580b92379c0461f80dcb3d31964
​ apiVersion=34.0
​ sf.server=https://test.salesforce.com
​ sf.maxPoll=20
​ sf.orgserver=cs7
Sample ANT Property File
ANT build file and configuration
​ All build targets are defined in build.xml file in repository root.
​ We will just touch on capabilities of ANT
•  For complete documentation, visit http://ant.apache.org
​ Specify which property file to get credentials from with a -propertyfile {path to property file}
option
​ Macros and Targets are primary components of the build.xml file.
ANT Build File
​ Pre-defined steps to invoke Data Loader ProcessRunner Java program.
•  Create process template copy
•  Perform token substitution based on property file values and command line arguments
•  Invoke Java program with process file
​ The following macros are already defined for you in the build.xml file:
•  sfExport, sfUpsert, sfDelete
Macros
ANT Build File
​ A target defines one or more commands to execute sequentially.
​ Target definitions can also specify dependent targets that must run first.
​ The following targets are already defined in the github build.xml file:
•  initDataDirectory
•  exportData
•  updateDataFiles
•  upsertData
•  deleteData
Targets
ANT Build File
​ Creates org-specific temp subdirectory under orgs and data directory beneath that.
​ Parameters:
​ -propertyfile {path to property file}
initDataDirectory Target
ANT Build File
ant initDataDirectory –propertyfile properties/sandbox.properties
​ Exports data in CSV format from specified org to org specific data subdirectory
​ Output file location: orgs/{orgname}/data/Obj__cExport.csv
​ Parameters:
​ -propertyfile {path to property file}
​ -Dobject={object name}
​ -Dsoql={SOQL to filter data}
exportData Target
ANT Build File
ant exportData –Dobject=Obj__c –Dsoql=“SELECT Id FROM Obj__c” –propertyfile properties/
sandbox.properties
​ Copies all export files from org data subdirectory to datascripts/datafiles staging directory.
​ Also renames Export.csv portion of the file name to Import.csv.
​ Parameters:
​ -propertyfile {path to property file}
updateDataFiles Target
ANT Build File
ant updateDataFiles –propertyfile properties/sandbox.properties
​ Upserts data from CSV format file in datascripts/datafiles directory to org specified in property
file.
​ Input file location: datascripts/datafiles/Obj__cImport.csv
​ Parameters:
​ -propertyfile {path to property file}
​ -Dobject={object name}
upsertData Target
ANT Build File
ant upsertData –Dobject=Obj__c –propertyfile properties/sandbox.properties
​ Deletes data for the requested object in the org specified in the property file.
​ Parameters:
​ -propertyfile {path to property file}
​ -Dobject={object name}
​ -Dsoql={SOQL query to define filter for data to delete}
deleteData Target
ANT Build File
ant deleteData –Dobject=Obj__c –Dsoql=“SELECT Id FROM Obj__c” –propertyfile properties/
sandbox.properties
Demo
Export Object Records to CSV
Demo
Import Object Records from CSV
Scripting Imports and Exports
​ Call initDataDirectory first to create / initialize directories
​ Call exportData for each object you want to export – order does not matter
When creating SOQL, remember to select ALL of the fields specified in export mapping file
Export Scripting Tips
Scripting Imports and Exports
Call upsertData for each object you want to import
Order matters with imports
•  Upsert objects with no lookups or M-D relationships first
•  Then import in dependency order
Disable your triggers prior to running import to avoid governor limit exceptions
​ Make sure to run updateDataFiles target prior to running import script.
•  You could work this into either the export or import scripts depending on your typical workflow
Import Scripting Tips
Scripting Imports and Exports
Demo
Export and Import Full Data Model
Use Cases
​ Pre-loading sandboxes
•  Developers need data
•  QA needs data too
•  Sometimes very different data needs
​ Continuous Integration
•  Jenkins / Bamboo / Travis etc.
•  Pre-populate sandboxes
​ Production issue troubleshooting and resolution
•  Do not make code fixes directly in production!
Use Cases for Scripted Data Loads
Case Study
​ Varsity Colors application is a product management and e-commerce application built on
Salesforce and Heroku.
​ Main Problem:
•  How to get data for items that are having issues in production into a sandbox for isolated troubleshooting
and resolution?
Case Study: Varsity Colors
​ Highly configured products.
•  Apparel with color, size options
•  Designs are customized for each school by layer colors, school names, mascots, fonts, etc.
​ 400+ base products configured for 180 different color schemes and 800 different schools.
​ Non-trivial data model for product catalog (> 40 objects) to store configuration options.
Data Model
Case Study: Varsity Colors
​ Took about eight hours to build all the SDL mapping files out
•  Some of the objects have over 40 custom fields
•  Product object hierarchy is approximately 9 levels deep through a combination of master-detail and
lookup relationships.
​ Took some additional time (via trial and error) to determine correct load order for imports.
Solution
Case Study: Varsity Colors
​ On full catalog import, needed to disable a few triggers as there are a few objects with almost 1M
records and we hit governor limits on triggers.
•  Re-run trigger logic with Apex batch scripts after.
​ Developer orgs are too small for full production catalog.
•  Use SOQL to define subset for development work.
Issues
Case Study: Varsity Colors
​ Full data export of the product catalog from production can be done in approximately 30 minutes
with a single command from a terminal window.
​ SOQL can be used to selectively choose smaller data sets to export for development or
debugging.
​ Full import into target org can be done in approximately the same time with also a single
command.
​ Extended this solution to export account and team catalog data relevant to a subset of schools to
avoid having to manually set up account storefronts.
Results
Case Study: Varsity Colors
Summary and Tips
​ Don’t set up data by hand – your time is too valuable
​ Invest the time to set data scripts up for all of your applications and target stakeholders – it will
pay huge dividends pretty quickly
​ Work with stakeholders (developers, QA teams) to define data needs
​ Add Load_ID to all objects you create to future-proof your orgs for scripted data
​ Have your developers and admins build SDL export and import files whenever they create new
objects
Summary And Tips
​ Use my github repository as a starting point, then adjust and innovate to meet your needs
​ Version your SDL mapping files, but not your SFDC property files
​ Be aware of governor limits on imports and developer sandbox data size limitations and plan
accordingly
​ Use SOQL judiciously to reduce your data sets
Summary And Tips
​ Github repository
•  git clone https://github.com/scottgeosits/sfdc-dataload-tutorial
​ Scripting Data Loads for Salesforce, parts 1 & 2
•  http://bit.ly/1GGHfq8
•  http://bit.ly/1HSnr4u
​ Data Loader Guide
•  http://sforce.co/1xUWr0I
​ Data Loader github: https://github.com/forcedotcom/dataloader
For More Information
Q & A
Thank you

More Related Content

What's hot (17)

PDF
Self service BI overview + Power BI
Arthur Graus
 
PDF
Microsoft Power BI Technical Overview
David J Rosenthal
 
PPTX
Introduction to Power BI to make smart decisions
VIVEK GURURANI
 
PDF
Learn How to Use Microsoft Power BI for Office 365 to Analyze Salesforce Data
Netwoven Inc.
 
PDF
Introduction to Power BI
HARIHARAN R
 
PPTX
Introduction to Power BI: Explore the Power BI interface
harshagrawal2001haru
 
PPTX
35 power bi presentations
Sean Brady
 
PDF
Data Visualisation & Analytics with Tableau (Beginner) - by Maria Koumandraki
Outreach Digital
 
PPTX
SAP BO Web Intelligence Basics
Kiran Joy
 
PDF
Microsoft Power BI Overview
Netwoven Inc.
 
PPTX
Power BI Overview
Nikkia Carter
 
PPTX
Tableau Prep.pptx
Venneladonthireddy1
 
PDF
Azure Synapse 101 Webinar Presentation
Matthew W. Bowers
 
PPTX
Tableau Visual analytics complete deck 2
Arun K
 
PPTX
Introduction to Tableau
Kanika Nagpal
 
PPTX
Data Visualization Trends - Next Steps for Tableau
Arunima Gupta
 
PPTX
Tableau
Nilesh Patel
 
Self service BI overview + Power BI
Arthur Graus
 
Microsoft Power BI Technical Overview
David J Rosenthal
 
Introduction to Power BI to make smart decisions
VIVEK GURURANI
 
Learn How to Use Microsoft Power BI for Office 365 to Analyze Salesforce Data
Netwoven Inc.
 
Introduction to Power BI
HARIHARAN R
 
Introduction to Power BI: Explore the Power BI interface
harshagrawal2001haru
 
35 power bi presentations
Sean Brady
 
Data Visualisation & Analytics with Tableau (Beginner) - by Maria Koumandraki
Outreach Digital
 
SAP BO Web Intelligence Basics
Kiran Joy
 
Microsoft Power BI Overview
Netwoven Inc.
 
Power BI Overview
Nikkia Carter
 
Tableau Prep.pptx
Venneladonthireddy1
 
Azure Synapse 101 Webinar Presentation
Matthew W. Bowers
 
Tableau Visual analytics complete deck 2
Arun K
 
Introduction to Tableau
Kanika Nagpal
 
Data Visualization Trends - Next Steps for Tableau
Arunima Gupta
 
Tableau
Nilesh Patel
 

Viewers also liked (20)

PPTX
Solving Complex Data Load Challenges
Sunand P
 
PPTX
The definitive guide to salesforce sandbox flosum
Flosum
 
PDF
Salesforce creating on_demand_apps
willsco
 
PDF
Single Sign-On and User Management for Portals and Communities
Salesforce Developers
 
PPT
Single Sign-On and User Management With Salesforce Identity
Salesforce Developers
 
PPTX
Hands-on with OAuth, Facebook and the Force.com Platform
Pat Patterson
 
PDF
Integrating Active Directory with Salesforce
Salesforce Developers
 
PDF
Salesforce Identity: Don't Treat Your Customers Like Your Employees
Salesforce Developers
 
PDF
Salesforce Identity: Connect and Collaborate Anywhere, Securely with Single S...
Perficient, Inc.
 
PDF
Introducing Salesforce Identity
Salesforce Developers
 
PDF
Salesforce Identity: Identity Management Made Easy
Salesforce Developers
 
PDF
Single Sign-On and User Provisioning with Salesforce Identity
Salesforce Developers
 
PPTX
O auth, sso, saml, canvas app zhugin(final)
Dmitry Zhugin
 
PPTX
Heroku - developer playground
Troy Sellers
 
PDF
CIS14: OAuth and OpenID Connect in Action
CloudIDSummit
 
PPTX
Trust Me, I'm An Architect
Keir Bowden
 
PPTX
Seamless Authentication with Force.com Canvas
Salesforce Developers
 
PPTX
Force.com Canvas: Salesforce1, SAML, & Apex...Oh My!
Salesforce Developers
 
PDF
Integrating Active Directory With Salesforce Using Identity Connect
Salesforce Developers
 
PPT
Designing custom REST and SOAP interfaces on Force.com
Steven Herod
 
Solving Complex Data Load Challenges
Sunand P
 
The definitive guide to salesforce sandbox flosum
Flosum
 
Salesforce creating on_demand_apps
willsco
 
Single Sign-On and User Management for Portals and Communities
Salesforce Developers
 
Single Sign-On and User Management With Salesforce Identity
Salesforce Developers
 
Hands-on with OAuth, Facebook and the Force.com Platform
Pat Patterson
 
Integrating Active Directory with Salesforce
Salesforce Developers
 
Salesforce Identity: Don't Treat Your Customers Like Your Employees
Salesforce Developers
 
Salesforce Identity: Connect and Collaborate Anywhere, Securely with Single S...
Perficient, Inc.
 
Introducing Salesforce Identity
Salesforce Developers
 
Salesforce Identity: Identity Management Made Easy
Salesforce Developers
 
Single Sign-On and User Provisioning with Salesforce Identity
Salesforce Developers
 
O auth, sso, saml, canvas app zhugin(final)
Dmitry Zhugin
 
Heroku - developer playground
Troy Sellers
 
CIS14: OAuth and OpenID Connect in Action
CloudIDSummit
 
Trust Me, I'm An Architect
Keir Bowden
 
Seamless Authentication with Force.com Canvas
Salesforce Developers
 
Force.com Canvas: Salesforce1, SAML, & Apex...Oh My!
Salesforce Developers
 
Integrating Active Directory With Salesforce Using Identity Connect
Salesforce Developers
 
Designing custom REST and SOAP interfaces on Force.com
Steven Herod
 
Ad

Similar to Scripted Data Loads with Salesforce DataLoader and ANT (20)

PPT
Data Management and Migration in Salesforce
Sunil kumar
 
PPTX
SFDC Data Loader
Sujit Kumar
 
DOCX
Data migration
mallareddy0107
 
PDF
WEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
CodeScience
 
PDF
Salesforce command line data loader
jakkula1099
 
PPTX
Salesforce data model
Jean Brenda
 
PDF
Salesforce Integration: Talking the Pain out of Data Loading
Darren Cunningham
 
PPT
Importing data to salesforce
NetStronghold
 
PPTX
Salesforce admin training 4
HungPham381
 
PDF
Salesforce Import Tools
Doria Hamelryk
 
PPTX
LDV.pptx
Shams Pirzada
 
PDF
Diagramming Salesforce Solutions: Matthew Morris - Jacksonville Architects - ...
A. Engin Utkan
 
PDF
Most Common Challenges in Salesforce Integration
Solunus, Inc.
 
PPTX
LDV-v2.pptx
Shams Pirzada
 
PDF
Beyond Custom Metadata Types
Salesforce Developers
 
PPTX
Deep Dive into Salesforce Integrations: Mapping Engines
CRMScienceKirk
 
PDF
Salesforce Data Export Solutions by Sastorm Software.pdf
sastormsoftware
 
PDF
Import data rahul vishwanath
mohamed refaei
 
PDF
Introduction to External Objects and the OData Connector
Salesforce Developers
 
PPTX
SFDC Database Basics
Sujit Kumar
 
Data Management and Migration in Salesforce
Sunil kumar
 
SFDC Data Loader
Sujit Kumar
 
Data migration
mallareddy0107
 
WEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
CodeScience
 
Salesforce command line data loader
jakkula1099
 
Salesforce data model
Jean Brenda
 
Salesforce Integration: Talking the Pain out of Data Loading
Darren Cunningham
 
Importing data to salesforce
NetStronghold
 
Salesforce admin training 4
HungPham381
 
Salesforce Import Tools
Doria Hamelryk
 
LDV.pptx
Shams Pirzada
 
Diagramming Salesforce Solutions: Matthew Morris - Jacksonville Architects - ...
A. Engin Utkan
 
Most Common Challenges in Salesforce Integration
Solunus, Inc.
 
LDV-v2.pptx
Shams Pirzada
 
Beyond Custom Metadata Types
Salesforce Developers
 
Deep Dive into Salesforce Integrations: Mapping Engines
CRMScienceKirk
 
Salesforce Data Export Solutions by Sastorm Software.pdf
sastormsoftware
 
Import data rahul vishwanath
mohamed refaei
 
Introduction to External Objects and the OData Connector
Salesforce Developers
 
SFDC Database Basics
Sujit Kumar
 
Ad

More from Salesforce Developers (20)

PDF
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Salesforce Developers
 
PDF
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Salesforce Developers
 
PDF
Local development with Open Source Base Components
Salesforce Developers
 
PPTX
TrailheaDX India : Developer Highlights
Salesforce Developers
 
PDF
Why developers shouldn’t miss TrailheaDX India
Salesforce Developers
 
PPTX
CodeLive: Build Lightning Web Components faster with Local Development
Salesforce Developers
 
PPTX
CodeLive: Converting Aura Components to Lightning Web Components
Salesforce Developers
 
PPTX
Enterprise-grade UI with open source Lightning Web Components
Salesforce Developers
 
PPTX
TrailheaDX and Summer '19: Developer Highlights
Salesforce Developers
 
PDF
Live coding with LWC
Salesforce Developers
 
PDF
Lightning web components - Episode 4 : Security and Testing
Salesforce Developers
 
PDF
LWC Episode 3- Component Communication and Aura Interoperability
Salesforce Developers
 
PDF
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
PDF
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
PDF
Migrating CPQ to Advanced Calculator and JSQCP
Salesforce Developers
 
PDF
Scale with Large Data Volumes and Big Objects in Salesforce
Salesforce Developers
 
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
Salesforce Developers
 
PDF
Modern Development with Salesforce DX
Salesforce Developers
 
PDF
Get Into Lightning Flow Development
Salesforce Developers
 
PDF
Integrate CMS Content Into Lightning Communities with CMS Connect
Salesforce Developers
 
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Salesforce Developers
 
Local development with Open Source Base Components
Salesforce Developers
 
TrailheaDX India : Developer Highlights
Salesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Salesforce Developers
 
CodeLive: Build Lightning Web Components faster with Local Development
Salesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
Salesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Salesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
Salesforce Developers
 
Live coding with LWC
Salesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Salesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
Salesforce Developers
 
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Salesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Salesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Salesforce Developers
 
Modern Development with Salesforce DX
Salesforce Developers
 
Get Into Lightning Flow Development
Salesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Salesforce Developers
 

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Python basic programing language for automation
DanialHabibi2
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 

Scripted Data Loads with Salesforce DataLoader and ANT

  • 1. Scripted Data Loads with Salesforce Data Loader and ANT ​ Scott Geosits ​ Salesforce.com Architect, Varsity Brands Inc. ​ sjgeosits@herffjones.com ​ @ScottGeosits ​ 
  • 8. ​  Why Scripted Data Loads? ​  Tools – Salesforce Data Loader and ANT ​  Setting Things Up ​  Creating And Running Scripts ​  Use Cases ​  Summary Agenda
  • 12. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 13. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox SANDBOX REFRESH
  • 14. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 15. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 16. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 17. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox DATA IN SYNC
  • 18. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 19. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox SANDBOX REFRESH
  • 20. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 21. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 22. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 23. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 24. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 25. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 26. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 27. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 28. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 29. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox DATA IN SYNC
  • 30. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox
  • 31. Why Scripted Data Loads? Full Copy Sandbox Sandbox Sandbox Sandbox Sandbox SANDBOX REFRESH data jenga
  • 33. Why Scripted Data Loads? ​ There HAS to be a better way!
  • 34. ​ Predictable and Repeatable data sets ​ Easy re-load of data after sandbox refreshes •  You SHOULD be refreshing from production OFTEN – after every prod release at a minimum •  git versioning + scripted data loads means you are productive much sooner after a refresh ​ CI for Selenium / Cucumber style testing in addition to Apex Unit Tests ​ Much better handling of object relationships •  All but most simple data models have relationships •  Data loader client requires you to manipulate CSV files to support relationships •  External ID with UPSERT is how we load data with relationships Benefits of Scripted Data
  • 35. Great. So how do we do this?
  • 36. Tools
  • 37. ​ Salesforce-provided utility for exporting and importing data from a Salesforce org or sandbox ​ CSV file format ​ Available from within Salesforce ​ Save mapping files for repeated operations ​ Load up to 5,000,000 records ​ Run from desktop or command line Salesforce Data Loader
  • 38. ​ Open source scripting tool ​ Part of Apache project – https://ant.apache.org ​ Define build steps via set of XML target definitions (build file) ​ Supports external build tasks, dependency chains ​ Like make but a hundred thousand times better ​ We will use this to run data loader by making calls to the data loader’s JAR file Apache ANT
  • 40. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github
  • 41. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github ANT build.xml file
  • 42. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github Executable utilities
  • 43. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github SDL mapping files Pre-built CSV data files
  • 44. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github Supporting Java JAR files
  • 45. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github Credentials for SFDC orgs
  • 46. ​ Everything we talk about here is in a github repo for you to experiment with ​ Use consistent structure across projects github Sample import / export scripts
  • 47. Setup
  • 49. ​ Salesforce record IDs do not match between production and sandboxes •  Well, not exactly: full copy sandbox IDs match, but we are not typically data loading those ​ External ID is needed to preserve object relationships ​ Our convention will be to create a field called Load_ID__c on all of our objects. •  Text field with length = 18 •  External ID = true Setting Up Objects
  • 50. ​ Why do we need to do this? Let’s look at a simple example ​ We have an org that has two accounts •  ABC Computers – Salesforce ID = 001F000000yHO3ZIAW •  XYZ Consulting – Salesforce ID = 001F000000yHO3ZIAX ​ Each of these accounts has two contacts: •  John Jones (ABC Computers) – Salesforce ID = 003a000000xJP2QIAW •  Jane Peters (ABC Computers) – Salesforce ID = 003a000000xJP3QIAW •  Jim Smith (XYZ Consulting) – Salesforce ID = 003a000000xJP4QIAW •  Maria Brown (XYZ Consulting) – Salesforce ID = 003a000000xJP5QIAW Load ID Setting Up Objects
  • 51. ​ If we do a field-by-field export of both objects, we end up with the following two files: Load ID Setting Up Objects
  • 52. ​ Now if we import these into a sandbox, they will import with different Salesforce IDs: •  ABC Computers – Salesforce ID = 001g000000yCW4xIAN •  XYZ Consulting – Salesforce ID = 001g000000yCW4yIAN ​ Looking back at our original records, we see we have a problem as the IDs do not match so we won’t be able to match the contact records up correctly: •  ABC Computers – Salesforce ID = 001F000000yHO3ZIAW •  XYZ Consulting – Salesforce ID = 001F000000yHO3ZIAX ​ Using desktop Data Loader, here’s where you would go in by hand and switch all of the Account values in the Contact CSV file to match the new IDs. Load ID Setting Up Objects
  • 53. ​ If we use external IDs, however, we can upsert on those external IDs ​ Similar to loading a contact list by email address. ​ Email address is not a primary key in Salesforce but set up as external ID and upsert can match on it. ​ We will steal borrow this pattern and use it to our advantage. Load ID Setting Up Objects
  • 54. ​ When we export, we put the Salesforce ID into a field called Load_ID__c in the CSV and end up with the following two files: Load ID Setting Up Objects
  • 55. ​ Now when we import, we tell the data loader to upsert that record into the database using the Load_ID__c external ID, and we get: •  ABC Computers – Salesforce ID = 001g000000yCW4xIAN, Load_ID__c = 001F000000yHO3ZIAW •  XYZ Consulting – Salesforce ID = 001g000000yCW4yIAN, Load_ID__c = 001F000000yHO3ZIAX ​ Comparing against our originals, the Salesforce IDs are different but we’ve preserved the ID from the source org in our Load ID field: •  ABC Computers – Salesforce ID = 001F000000yHO3ZIAW •  XYZ Consulting – Salesforce ID = 001F000000yHO3ZIAX Load ID Setting Up Objects
  • 56. ​ We also tell it when establishing the relationships to do so using the Load ID external ID and NOT the record primary key Salesforce ID. ​ We then get the record inserted with the correct relationship established to the new account record: •  Contact John Jones •  Salesforce ID = 003J000000xZD7GIAW •  Load ID = 003a000000xJP2QIAW •  Account = 001g000000yCW4xIAN ​ Note that once the upsert occurs the record is in the target system with the NEW account Salesforce ID, not the actual Load ID from the old system. Load ID Setting Up Objects
  • 58. ​ Define mapping of fieldnames from CSV to Salesforce object and vice versa ​ Text file containing source field name, equals sign, destination field name •  Must use Salesforce API Field Name, not Label •  Keep things simple! Use Salesforce API fieldnames for CSV column names. ​ Need to create one mapping file for export and another one for import •  Naming conventions used by ANT build script: •  Export file: {Salesforce object API Name}ExportMap.sdl - ex. Candidate__cExportMap.sdl •  Import file: {Salesforce object API Name}ImportMap.sdl - ex. Candidate__cImportMap.sdl ​ Export mappings have Salesforce field name on left, CSV column name on right Export Files SDL Mapping Files
  • 60. ​ Special notation for relationship fields ​ Need to specify that when a record is imported, it links the object to the related object (which must already be in the database) via the related object’s Load_ID__c field. ​ We do this with the __r: notation: •  Candidate__c=Candidate__r:Load_ID__c Import Files SDL Mapping Files
  • 61. ​ Special notation for relationship fields ​ Need to specify that when a record is imported, it links the object to the related object (which must already be in the database) via the related object’s Load_ID__c field. ​ We do this with the __r: notation: •  Candidate__c=Candidate__r:Load_ID__c Import Files SDL Mapping Files
  • 62. ​ Special notation for relationship fields ​ Need to specify that when a record is imported, it links the object to the related object (which must already be in the database) via the related object’s Load_ID__c field. ​ We do this with the __r: notation: •  Candidate__c=Candidate__r:Load_ID__c ​ This tells data loader to establish the relationship to the Candidate__c object by matching the value in the CSV file (Candidate__c) to the Candidate__c record with a matching Load_ID__c value. Import Files SDL Mapping Files
  • 66. ​ Store Salesforce authentication credentials •  Username •  Encrypted password •  Org server and name •  Salesforce server ​ Each environment gets one ​ Do NOT version these in git Setting Up ANT Property Files
  • 67. ​ Must encrypt password using Data Loader encryption utility •  Encryption utility found under bin/ in Data Loader install directory •  Also available under bin/ in my github repository •  Encryption key needed – seed value for hash generator •  There is one called dataloaderencryptionkey.txt under datascripts/ directory – feel free to modify •  If you rename, you must rename in template files under datascripts/ as well ​ Encrypt password + security token Creating Encrypted Passwords
  • 68. ​ Copy result to your properties file ​ One time operation, until your password or security token is modified Creating Encrypted Passwords ./encrypt.sh –e {password + securitytoken} ../datascripts/dataloader_encryption_key.txt
  • 70. ANT build file and configuration
  • 71. ​ All build targets are defined in build.xml file in repository root. ​ We will just touch on capabilities of ANT •  For complete documentation, visit http://ant.apache.org ​ Specify which property file to get credentials from with a -propertyfile {path to property file} option ​ Macros and Targets are primary components of the build.xml file. ANT Build File
  • 72. ​ Pre-defined steps to invoke Data Loader ProcessRunner Java program. •  Create process template copy •  Perform token substitution based on property file values and command line arguments •  Invoke Java program with process file ​ The following macros are already defined for you in the build.xml file: •  sfExport, sfUpsert, sfDelete Macros ANT Build File
  • 73. ​ A target defines one or more commands to execute sequentially. ​ Target definitions can also specify dependent targets that must run first. ​ The following targets are already defined in the github build.xml file: •  initDataDirectory •  exportData •  updateDataFiles •  upsertData •  deleteData Targets ANT Build File
  • 74. ​ Creates org-specific temp subdirectory under orgs and data directory beneath that. ​ Parameters: ​ -propertyfile {path to property file} initDataDirectory Target ANT Build File ant initDataDirectory –propertyfile properties/sandbox.properties
  • 75. ​ Exports data in CSV format from specified org to org specific data subdirectory ​ Output file location: orgs/{orgname}/data/Obj__cExport.csv ​ Parameters: ​ -propertyfile {path to property file} ​ -Dobject={object name} ​ -Dsoql={SOQL to filter data} exportData Target ANT Build File ant exportData –Dobject=Obj__c –Dsoql=“SELECT Id FROM Obj__c” –propertyfile properties/ sandbox.properties
  • 76. ​ Copies all export files from org data subdirectory to datascripts/datafiles staging directory. ​ Also renames Export.csv portion of the file name to Import.csv. ​ Parameters: ​ -propertyfile {path to property file} updateDataFiles Target ANT Build File ant updateDataFiles –propertyfile properties/sandbox.properties
  • 77. ​ Upserts data from CSV format file in datascripts/datafiles directory to org specified in property file. ​ Input file location: datascripts/datafiles/Obj__cImport.csv ​ Parameters: ​ -propertyfile {path to property file} ​ -Dobject={object name} upsertData Target ANT Build File ant upsertData –Dobject=Obj__c –propertyfile properties/sandbox.properties
  • 78. ​ Deletes data for the requested object in the org specified in the property file. ​ Parameters: ​ -propertyfile {path to property file} ​ -Dobject={object name} ​ -Dsoql={SOQL query to define filter for data to delete} deleteData Target ANT Build File ant deleteData –Dobject=Obj__c –Dsoql=“SELECT Id FROM Obj__c” –propertyfile properties/ sandbox.properties
  • 82. ​ Call initDataDirectory first to create / initialize directories ​ Call exportData for each object you want to export – order does not matter When creating SOQL, remember to select ALL of the fields specified in export mapping file Export Scripting Tips Scripting Imports and Exports
  • 83. Call upsertData for each object you want to import Order matters with imports •  Upsert objects with no lookups or M-D relationships first •  Then import in dependency order Disable your triggers prior to running import to avoid governor limit exceptions ​ Make sure to run updateDataFiles target prior to running import script. •  You could work this into either the export or import scripts depending on your typical workflow Import Scripting Tips Scripting Imports and Exports
  • 84. Demo Export and Import Full Data Model
  • 86. ​ Pre-loading sandboxes •  Developers need data •  QA needs data too •  Sometimes very different data needs ​ Continuous Integration •  Jenkins / Bamboo / Travis etc. •  Pre-populate sandboxes ​ Production issue troubleshooting and resolution •  Do not make code fixes directly in production! Use Cases for Scripted Data Loads
  • 88. ​ Varsity Colors application is a product management and e-commerce application built on Salesforce and Heroku. ​ Main Problem: •  How to get data for items that are having issues in production into a sandbox for isolated troubleshooting and resolution? Case Study: Varsity Colors
  • 89. ​ Highly configured products. •  Apparel with color, size options •  Designs are customized for each school by layer colors, school names, mascots, fonts, etc. ​ 400+ base products configured for 180 different color schemes and 800 different schools. ​ Non-trivial data model for product catalog (> 40 objects) to store configuration options. Data Model Case Study: Varsity Colors
  • 90. ​ Took about eight hours to build all the SDL mapping files out •  Some of the objects have over 40 custom fields •  Product object hierarchy is approximately 9 levels deep through a combination of master-detail and lookup relationships. ​ Took some additional time (via trial and error) to determine correct load order for imports. Solution Case Study: Varsity Colors
  • 91. ​ On full catalog import, needed to disable a few triggers as there are a few objects with almost 1M records and we hit governor limits on triggers. •  Re-run trigger logic with Apex batch scripts after. ​ Developer orgs are too small for full production catalog. •  Use SOQL to define subset for development work. Issues Case Study: Varsity Colors
  • 92. ​ Full data export of the product catalog from production can be done in approximately 30 minutes with a single command from a terminal window. ​ SOQL can be used to selectively choose smaller data sets to export for development or debugging. ​ Full import into target org can be done in approximately the same time with also a single command. ​ Extended this solution to export account and team catalog data relevant to a subset of schools to avoid having to manually set up account storefronts. Results Case Study: Varsity Colors
  • 94. ​ Don’t set up data by hand – your time is too valuable ​ Invest the time to set data scripts up for all of your applications and target stakeholders – it will pay huge dividends pretty quickly ​ Work with stakeholders (developers, QA teams) to define data needs ​ Add Load_ID to all objects you create to future-proof your orgs for scripted data ​ Have your developers and admins build SDL export and import files whenever they create new objects Summary And Tips
  • 95. ​ Use my github repository as a starting point, then adjust and innovate to meet your needs ​ Version your SDL mapping files, but not your SFDC property files ​ Be aware of governor limits on imports and developer sandbox data size limitations and plan accordingly ​ Use SOQL judiciously to reduce your data sets Summary And Tips
  • 96. ​ Github repository •  git clone https://github.com/scottgeosits/sfdc-dataload-tutorial ​ Scripting Data Loads for Salesforce, parts 1 & 2 •  http://bit.ly/1GGHfq8 •  http://bit.ly/1HSnr4u ​ Data Loader Guide •  http://sforce.co/1xUWr0I ​ Data Loader github: https://github.com/forcedotcom/dataloader For More Information
  • 97. Q & A