SlideShare a Scribd company logo
SFDC Data Models for Pros -
Simplifying The Complexities
​ Baruch Oxman
​ R&D Manager, Implisit
​ @implisithq, @baruchoxman
Baruch Oxman
R&D Manager
Implisit – Intro & Motivation
Implisit – Intro & Motivation
Data Entry, Insights
& Analytics
Standalone UI
Real-time SFDC
Data interaction
Offline SFDC Data
Processing
Connected App UI
In this session
Object Relationship
Types
Polymorphic
Relations
Security &
Permissions
Deleted RecordsMetadata
History Records
Objects Relationships
•  Master-Detail
•  One-to-Many
•  Lookup
•  Many-to-Many
•  Polymorphic relations
Object Relations
•  Closely linked objects
•  Detail extends the master
•  Owner of master owns the child record
•  Example:
•  Custom “AccountDetails” object, extending Account
Master-Detail Relationship
Master
Detail
One-to-Many
Opportunity
Opportunity
Competitor
Opportunity
Competitor
Opportunity
Competitor
Lookup
Account
Contact Contact Contact
Many-to-Many
Contact Lead
Campaign Campaign
Task Task
Contact Contact
Many-to-Many
CampaignCampaign Contact Contact
Campaign
Member
Campaign
Member
Campaign
Member TaskRelation TaskRelation TaskRelation
Task TaskLeadContact
Tasks & Events
Polymorphic Relations
Polymorphic Relations
Task Attachment
Contact/Lead
Opportunity/Case/
Account
Opportunity/Case/Account/Contact/Lead/…
WhatId WhoId ParentId
Challenge
​ SELECT Subject, Account.Name, Who.Company FROM Task
Error: “No such column 'Company' on entity 'Name'…”
Naïve Approach
1. SELECT Subject, Account.Name, WhoId FROM Task
2. SELECT Company FROM Lead WHERE Id IN <WhoId list from previous query>
1st option: 2 SOQL queries
​ SELECT Subject, Account.Name,
TYPEOF Who
WHEN Lead THEN Company
END
FROM Task
•  Developer preview, to enable - contact Salesforce
2nd option: TYPEOF
​ SELECT Id, Company,
(SELECT Id
FROM Tasks
WHERE <tasks filtering condition>)
FROM Lead
Nested SOQL Query
​ { 'totalSize': 2,
​  'records': [
​  {'Company': ‘Salesforce.com', u'Tasks': None, u'Id': u'00Qd0000007Q36GEAS'},
​  {'Company': ‘Implisit',
​  'Tasks': {'totalSize': 1, u'records': [{'Id': u'00Ti000000zM7rLEAS'}]},
​  'Id': u'00Qd0000007Q36GEAS'}
​ ]}
Nested SOQL Query - result
​ SELECT Id, Who.Name FROM Task WHERE Who.Type = ‘Lead’
TYPE qualifier
History records
Motivation
History records
Accounts
Cases
Products
Leads Contacts
Opportunities Contracts
Assets and more…
•  Field Name
•  Old Value
•  New Value
•  Id (AccountId / OpportunityId / ContactId / …)
•  Who changed it and when ?
•  Read-only records
Structure
​ {
​  "Id" : "017200000GScFz0AQF",
​  "Field" : "StageName",
​  "OldValue" : "Intro",
​  "NewValue" : "Closed Lost",
​  "OpportunityId" : "0062000000W1QT6AAN",
​  "CreatedById" : "00520000003KQCNAA4",
​  "CreatedDate" : "2014-02-24T09:39:04.000+0000",
​ }
OpportunityFieldHistory record - example
•  Monitoring a subset of fields:
• Amount
• Probability
• Stage
• Close Date
• Few more…
•  Each record contains the values for all these fields
•  Useful for pipeline snapshots
OpportunityHistory
​ {
​  "Id" : "00820000014EWPlAAO",
​  "Amount" : 5280.0,
​  "CloseDate" : "2014-12-31",
​  "ExpectedRevenue" : 5280.0,
​  "ForecastCategory" : "Closed",
​  "Probability" : 100.0,
​  "StageName" : "Closed Won",
​  "OpportunityId" : "0062000000W0TMNAA3",
​  "SystemModstamp" : "2015-01-22T08:41:32.000+0000",
​  "CreatedById" : "00520000003KQCNAA4",
​  "CreatedDate" : "2015-01-22T08:41:32.000+0000",
​ }
OpportunityHistory record - example
Security & Permissions
Security & Permissions
Objects Fields
Records Relations
Objects Metadata
​ from suds.client import Client
​ …
​ soap_api = Client(wsdl_url)
​ describe_global_res = soap_api.service.describeGlobal()
​ supported_obj_names = [sobject.name for describe_global_res['sobjects']]
describeGlobal() - list supported objects
​  (DescribeGlobalSObjectResult){
​  activateable = False
​  createable = True
​  custom = False
​  customSetting = False
​  deletable = True
​  deprecatedAndHidden = False
​  feedEnabled = True
​  keyPrefix = "001"
​  label = "Account"
​  labelPlural = "Accounts"
​  layoutable = True
​  mergeable = True
​  name = "Account"
​  queryable = True
​  replicateable = True
​  retrieveable = True
​  searchable = True
​  triggerable = True
​  undeletable = True
​  updateable = True
​  },
describeGlobal() – output example
​ get_desc_url = "https://na15.salesforce.com/services/data/v32/sobjects/Lead/describe"
desc_json = json.loads(perform_request(get_desc_url))
​ lead_fields_metadata = desc_json['fields']
​ // get all available field names
​ lead_field_names = [field['name'] for field in lead_fields_metadata]
Describe
​ [(DescribeSObjectResult){
​ …
​  activateable = False
​  keyPrefix = "00Q"
​  label = "Lead"
​  labelPlural = "Leads"
​  layoutable = True
​  mergeable = True
​  name = "Lead"
​  queryable = True
​  replicateable = True
​  retrieveable = True
​  searchLayoutable = True
​  searchable = True
​  triggerable = True
​  undeletable = True
​  updateable = True
​ ….
​ }]
Describe - output
​ # get all picklist values for a field
​ def get_active_picklist_values(obj_fields_metadata, field_name):
for field_metadata in fields_metadata:
if field_metadata['name'] != field_name:
continue
picklist_values = field_metadata.get('picklistValues', [])
return [ picklist_val['value']
for picklist_val in picklist_values
if picklist_val['active'] ]
Describe
​ (Field){
​  autoNumber = False
​  byteLength = 120
​  calculated = False
​  caseSensitive = False
​  createable = True
​  custom = False
​  defaultedOnCreate = False
​  deprecatedAndHidden = False
​  digits = 0
​  filterable = True
​  groupable = True
​  idLookup = False
​  label = "Lead Source"
​  length = 40
​  name = "LeadSource"
​  nameField = False
​  namePointing = False
​  nillable = True
​  permissionable = True
​  picklistValues[] =
​  (PicklistEntry){
​  active = True
​  defaultValue = False
​  label = "Advertisement"
​  value = "Advertisement"
​  },
​  ...
​  precision = 0
​  restrictedPicklist = False
​  scale = 0
​  soapType = "xsd:string"
​  sortable = True
​  type = "picklist"
​  unique = False
​  updateable = True
​  },
Describe – single field output
Tracking deleted records
getDeleted()
• SOAP
• Single API call
queryAll(isDeleted = True)
• REST
• Multiple API calls
• Recycle Bin objects
Tracking deleted records
Summary
Object Relationship
Types
Polymorphic
Relations
Security &
Permissions
Deleted RecordsMetadata
History Records
•  Object relationships types
•  SFDC Sales Objects relationships diagram
•  describeGlobal, describeSObject
•  SFDC Task & Event objects
•  SOQL Polymorphism
•  Understanding Polymorphic Keys and
Relationships
•  Polymorphic Lookups
•  TYPEOF
Additional Resources
Salesforce Data Models for Pros: Simplifying The Complexities
Salesforce Data Models for Pros: Simplifying The Complexities
Thank you

More Related Content

PPTX
Cloud computing & security basics
PDF
Real estate management system
PDF
Salesforce Shield: How to Deliver a New Level of Trust and Security in the Cloud
PDF
Salesforce Admin 201-certification Notes
PPTX
Cloud Security Fundamentals Webinar
PPTX
Salesforce introduction
PDF
How Salesforce CRM works & who should use it?
PPTX
online hotel management system
Cloud computing & security basics
Real estate management system
Salesforce Shield: How to Deliver a New Level of Trust and Security in the Cloud
Salesforce Admin 201-certification Notes
Cloud Security Fundamentals Webinar
Salesforce introduction
How Salesforce CRM works & who should use it?
online hotel management system

What's hot (20)

PDF
Introduction to Microsoft Enterprise Mobility + Security
PPTX
SOA And Cloud Computing
PPTX
Rhel cluster basics 1
PPTX
SCCM Intune Windows 10 Co Management Architecture Decisions
PPTX
Public Cloud vs Private Cloud – Choosing the Right Cloud Computing Environment!
PPTX
Salesforce admin training 2
PPTX
Introduction to public cloud
PPTX
Salesforce intro session_for_students_v2
PPTX
MFA-Powerpoint.pptx
PPTX
Transparent Encryption in HDFS
PDF
Cloud Computing Architecture
PDF
Veeam Presentation
PDF
Medical store system
PPTX
this ppt shows easy way to understand ONLINE HOTEL MANGEMENT
ODT
ER diagrami
PDF
Strategies for Effective Hardware and Software Asset Management
PPTX
Migrating into a cloud
PPTX
Monitoring in Azure
DOCX
Mobile store management
Introduction to Microsoft Enterprise Mobility + Security
SOA And Cloud Computing
Rhel cluster basics 1
SCCM Intune Windows 10 Co Management Architecture Decisions
Public Cloud vs Private Cloud – Choosing the Right Cloud Computing Environment!
Salesforce admin training 2
Introduction to public cloud
Salesforce intro session_for_students_v2
MFA-Powerpoint.pptx
Transparent Encryption in HDFS
Cloud Computing Architecture
Veeam Presentation
Medical store system
this ppt shows easy way to understand ONLINE HOTEL MANGEMENT
ER diagrami
Strategies for Effective Hardware and Software Asset Management
Migrating into a cloud
Monitoring in Azure
Mobile store management
Ad

Similar to Salesforce Data Models for Pros: Simplifying The Complexities (20)

PPTX
SFDC Data Models For Pros - Simplifying The Complexities
PDF
PHPUnit Episode iv.iii: Return of the tests
PDF
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
PPTX
Portfolio Oversight With eazyBI
PPTX
Introducing DataWave
PDF
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
PDF
Solr's Search Relevancy (Understand Solr's query debug)
PPTX
Open Source Search: An Analysis
PDF
Web Forms People Don't Hate
PDF
Crowdsourcing with Django
PPTX
Context-aware application development with FIWARE #CPBR8
PDF
Security Slicing for Auditing XML, XPath, and SQL Injection Vulnerabilities
PDF
Server Side Events
KEY
Building & Breaking Web Forms with Quaid-JS
PDF
Scaling business app development with Play and Scala
PDF
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
PDF
Test driven development with behat and silex
KEY
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
PDF
Leveraging Symfony2 Forms
SFDC Data Models For Pros - Simplifying The Complexities
PHPUnit Episode iv.iii: Return of the tests
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
Portfolio Oversight With eazyBI
Introducing DataWave
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
Solr's Search Relevancy (Understand Solr's query debug)
Open Source Search: An Analysis
Web Forms People Don't Hate
Crowdsourcing with Django
Context-aware application development with FIWARE #CPBR8
Security Slicing for Auditing XML, XPath, and SQL Injection Vulnerabilities
Server Side Events
Building & Breaking Web Forms with Quaid-JS
Scaling business app development with Play and Scala
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Test driven development with behat and silex
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Leveraging Symfony2 Forms
Ad

More from Salesforce Developers (20)

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

Recently uploaded (20)

PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
STKI Israel Market Study 2025 version august
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Architecture types and enterprise applications.pdf
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPT
What is a Computer? Input Devices /output devices
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Hybrid model detection and classification of lung cancer
Hindi spoken digit analysis for native and non-native speakers
A contest of sentiment analysis: k-nearest neighbor versus neural network
TLE Review Electricity (Electricity).pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
1 - Historical Antecedents, Social Consideration.pdf
STKI Israel Market Study 2025 version august
A novel scalable deep ensemble learning framework for big data classification...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
NewMind AI Weekly Chronicles - August'25-Week II
Chapter 5: Probability Theory and Statistics
Architecture types and enterprise applications.pdf
observCloud-Native Containerability and monitoring.pptx
Tartificialntelligence_presentation.pptx
cloud_computing_Infrastucture_as_cloud_p
Group 1 Presentation -Planning and Decision Making .pptx
What is a Computer? Input Devices /output devices
Web App vs Mobile App What Should You Build First.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Hybrid model detection and classification of lung cancer

Salesforce Data Models for Pros: Simplifying The Complexities