SlideShare a Scribd company logo
1 of 24
Deep dive into Salesforce Integrations:
Mapping Engines
Salesforce World Tour NYC June 18, 2015
Ami Assayag
Architect, CRM Science
Developer UG Leader, PhillyForce
@AmiAssayag
Speakers
Safe Harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties
materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or
implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking,
including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements
regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded
services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality
for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results
and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other
litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating
history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer
deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further
information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the
most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings
section of the Investor Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available
and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that
are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Agenda
• What is a mapping engine?
• Architecture overview?
• Support infrastructure
• Mapping types
• Code, code and more code!
What is a Mapping Engine?
• For the user
– User interface that provide flexibility to how the integration
interacts with the org.
– Allows pre-configuration and changes without development
• Beind the scene
– Supported by a code that handles outbound and inbound
transactions.
Why Use Mapping Engines for Integrations?
• Allows for more generic integrations
• Dynamic
– builds callout bodies
– Interprets incoming payloads
• Changes to external service can be handled without additional
development
Architecture Overview (Outbound)
Salesforce Org
External
System
Mapping
Data
Callout
Handler
Inbound
Mapping Engine
Outbound
Mapping Engine
Org Data
Apex REST
Trigger/Job
1
2
3
4
5
Architecture Overview (Inbound)
Salesforce Org
External
System
Mapping
Data
Callout
Handler
Inbound
Mapping Engine
Outbound
Mapping Engine
Org Data
Apex REST
Trigger/Job
12
3
4
Pillars of Mapping Engine Code
• Use object data type instead of specific types
• Cast custom and standard objects to sobject
• Build soql queries dynamically
• Use DMLOptions
Infrastructure Choices
• Mapping engines are database driven
• Data infrastructure options
– Custom objects
• Pro: easier to manage relationships
• Con: more directly accessible to users
– Custom setting
• Pro: can be protected, cached
• Con: difficult to manage relationships, requires data configuration
– Custom Metadata Types
• Pro: can include pre-configured data, can be protected, cached
• Con : difficult to manage relationships
Mapping Data Structure
• Important: The integration terminology is the “Master”
terminology because Salesforce mapping can be changed.
Object Mapping Object
Integration Object
Salesforce Object
Field Mapping Object
Integration Object
Integration Field
Salesforce Field
Mapping Type
Inbound
Outbound
Value Mapping Object
Integration Field
Integration Value
Salesforce Value
Inbound
Outbound
Simplified Field Mapping Data Structure
• Each field mapping record represents the mapping of a single field
between the two systems.
Field Mapping Object
Integration Object
Salesforce Object
Integration Field
Salesforce Field
Mapping Type
Inbound
Outbound
Values Example
= prospect
= Opportunity
= person.first_name
= Contact__r.Name
= Value
= true
= true
Mapping Types
• Regular Value – single value of any acceptable data type
• Constant – value that is defined by the mapping, not by the integration
• Value Map – sub mapping for value conversion (normally for picklists)
• Object – mapping of lookup relationships
• Related List – mapping of related list mapping
Integration Trigger
// Trigger to handle all callouts for the Opportunity object
trigger ContactIntegration on Contact(after insert) {
ProcessTrigger.sendInsertedRecords('Person', Trigger.newMap.keySet());
}
• Pass to static class
– Integration object name (not salesforce name)
– Triggered record ids (not actual objects because it is not likely to
contain all the information needed.
Prepare the Field Mapping
// property to hold field mappings per object
private map<string, list<FieldMapping__c>> fieldMappings;
public list<FieldMapping__c> getFieldMappings(string obj) {
// make sure the variable is instantiated
if (fieldMappings == null)
fieldMappings = new map<string, list<FieldMapping__c>>();
// check if the object mappings was already fetched
if (fieldMappings.get(obj) == null) {
// get the mappings for the object
fieldMappings.put(obj, [SELECT Name, SalesforceObject__c, SalesforceField__c,
IntegrationField__c, MappingType__c,
FROM FieldMapping__c
WHERE IntegrationObject__c = :obj
AND Incoming__c = true //can make this dynamic
LIMIT 1000]);
}
// return the list of mappings for the requested object
return fieldMappings.get(obj);
}
Re-Query the Triggered Records
// prepare a set of strings to hold all the field names (set prevents dups)
set<string> fieldsToSelect = new set<string>();
// get the field mapping for the specified object and collect the fields that need to be queried
for (FieldMapping__c mapping : getFieldMappings(objectName)) {
// exclude related list and constant mapping
if (mapping.MappingType__c != 'Related List' && mapping.MappingType__c != ‘Constant')
fieldsToSelect.add(mapping.SalesforceField__c);
}
// start a query string and add the select fields
string query = 'SELECT ';
for (string fieldToSelect : fieldsToSelect)
query += fieldToSelect + ',';
// remove the last comma
query = query.substring(0, query.length()-1);
// add the from and where clause
query += ' FROM ' + objectName + ' WHERE Id IN :' + recordIds;
// dynamically retrieve records into list of sobject
list<sObject> records = database.query(query);
Loop Through Records and Mappings
// recieve a list of records and create a json body to call the integration
public list<map<string, object>> processMapping(string objectName, list<sObject> records) {
// define a list of maps that contain value pairs that can be built
// dynamically and serialized.
// the list represents the array of sent records
// each map represents a single record
// the map keyset represent the integration field names
// the map values represent the field values in sfdc
list<map<string, object>> jsonStructure = new list<map<string, object>>();
object fieldValue;
// get the records from the database and loop through the records
for (sObject record : records) {
// prepare a map to hold the value pairs for the current record
map<string, object> outboundRecord = new map<string, object>();
// loop through each mapping record for this object
for (FieldMapping__c mapping : getFieldMappings(objectName)) {
// assemble value pairs
}
}
return jsonStructure ;
}
While Looping – Get the Value (Simple Value)
// check if any of the value need to be accessed through a lookup
list<string> FieldParts = fieldName.split('.');
// loop through all the associated objects to drill down to the actual referenced object
integer part = 0;
while (part < FieldParts.size() - 1) {
record = record.getSobject(FieldParts[part]);
// go to next node if the record is valued
if (record == null)
break;
else
part += 1;
}
// make sure the record is not null (example: if accountId is null, Account.name will cause a an exception)
if (record != null) {
// get the value from the record
retValue = record.get(FieldParts[part]);
// the last part is the field itself, use a simple get to return the value as a string.
// if value is null, don't process further (just return null)
if (retValue != null) {
// figure out the field type and do any conversion required by the integration }
}
}
While Looping – Add Value Pair
// split the integration field name - may need to add one or more nested objects before adding a value pair.
list<string> node = mapping.IntegrationField__c.split('.');
// prepare a map to hold a parent object. start with the outbound record reference
map<string, object> currentObject = outboundRecord;
// prepare a map to hold a nested object
map<string, object> nestedObject;
// loop through the integration nodes in the path and place each nested object/value
for (integer i = 0; i < node.size(); i++) {
if (i == node.size()-1) {
// this is the last node in the path (the value), so add it unless a dependent field is null
currentObject.put(node[i], fieldValue);
} else {
// check if the nested object already exists
if (currentObject.containsKey(node[i]))
nestedObject = (map<string, object>)(currentObject.get(node[i]));
else
// if the nested object was not found, instantiate one.
nestedObject = new map<string, object>();
// add the nested object to the current object
currentObject.put(node[i], nestedObject);
// make the nested object the next current object
currentObject = nestedObject;
}
}
}
Finish the loop and Serialize
. . . .
// if any field values were added for this record, add it to the
// outbound body
if (!outboundRecord.isEmpty())
jsonStructure.add(outboundRecord);
}
// deserialize the list of map so it is ready to be sent. Remove empty objects
if (!jsonStructure.isEmpty())
jsonBody = json.serialize(jsonStructure).remove('{}');
// returned the serialized structure
return jsonBody;
Ami Assayag
Architect, CRM Science
User Group Leader, PhillyForce
@AmiAssayag
Q & A
Thank you
Other Stuff
While Looping – Get the Value (other types)
// only process mappings that are not of type related list
if (mapping.MappingType__c == 'Constant') {
// this is a string value that is stored in the salesforce field
fieldValue = mapping.SalesforceField__c;
} else if (mapping.MappingType__c == 'Account' || mapping.MappingType__c == 'Contact')
// this is a lookup to a related object
// Get the Id and call processMapping recursively to get object’s value pairs;
} else { // Single Value or Value map
// get the field value from the record
fieldValue = retrieveValue(record, mapping.SalesforceField__c);
// check if the retrieved value needs to be mapped to other values
if (mapping.MappingType__c == 'Value Map')
// get the mapped value from the custom setting
fieldValue = getValueMapping(mapping.Name.toLowerCase(), string.valueof(fieldValue));
}

More Related Content

What's hot

Oracle primavera p6 and ebs projects where do they meet ppt
Oracle primavera p6 and ebs projects   where do they meet pptOracle primavera p6 and ebs projects   where do they meet ppt
Oracle primavera p6 and ebs projects where do they meet pptp6academy
 
Salesforce Cloud Infrastructure and Challenges - A Brief Overview
Salesforce Cloud Infrastructure and Challenges - A Brief OverviewSalesforce Cloud Infrastructure and Challenges - A Brief Overview
Salesforce Cloud Infrastructure and Challenges - A Brief OverviewSalesforce Engineering
 
206520 p6 web services programming interface
206520 p6 web services programming interface206520 p6 web services programming interface
206520 p6 web services programming interfacep6academy
 
Primavera integration possibilities Technical overview - Oracle Primavera Col...
Primavera integration possibilities Technical overview - Oracle Primavera Col...Primavera integration possibilities Technical overview - Oracle Primavera Col...
Primavera integration possibilities Technical overview - Oracle Primavera Col...p6academy
 
Integrating primavera p6 with oracle erp which technology path is right for...
Integrating primavera p6 with oracle erp   which technology path is right for...Integrating primavera p6 with oracle erp   which technology path is right for...
Integrating primavera p6 with oracle erp which technology path is right for...p6academy
 
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...Alithya
 
Solving todays problems with oracle integration cloud
Solving todays problems with oracle integration cloudSolving todays problems with oracle integration cloud
Solving todays problems with oracle integration cloudHeba Fouad
 
EPM Automate - Automating Enterprise Performance Management Cloud Solutions
EPM Automate - Automating Enterprise Performance Management Cloud SolutionsEPM Automate - Automating Enterprise Performance Management Cloud Solutions
EPM Automate - Automating Enterprise Performance Management Cloud SolutionsJoseph Alaimo Jr
 
Oracle Primavera Gateway 15.2 Webcast
Oracle Primavera Gateway 15.2 WebcastOracle Primavera Gateway 15.2 Webcast
Oracle Primavera Gateway 15.2 Webcastp6academy
 
FDMEE versus Cloud Data Management - The Real Story
FDMEE versus Cloud Data Management - The Real StoryFDMEE versus Cloud Data Management - The Real Story
FDMEE versus Cloud Data Management - The Real StoryJoseph Alaimo Jr
 
Oracle Planning and Budgeting Cloud Service
Oracle Planning and Budgeting Cloud ServiceOracle Planning and Budgeting Cloud Service
Oracle Planning and Budgeting Cloud ServiceDatavail
 
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14p6academy
 
What's New in Primavera Gateway 16.1
What's New in Primavera Gateway 16.1What's New in Primavera Gateway 16.1
What's New in Primavera Gateway 16.1p6academy
 
Interstellar - The Thomas Jefferson Enterprise EPM Cloud Journey
Interstellar - The Thomas Jefferson Enterprise EPM Cloud JourneyInterstellar - The Thomas Jefferson Enterprise EPM Cloud Journey
Interstellar - The Thomas Jefferson Enterprise EPM Cloud JourneyAlithya
 
Viasat Launches to the Cloud with Oracle Enterprise Data Management
Viasat Launches to the Cloud with Oracle Enterprise Data Management Viasat Launches to the Cloud with Oracle Enterprise Data Management
Viasat Launches to the Cloud with Oracle Enterprise Data Management Alithya
 
Essbase Calculations: Elements of Style
Essbase Calculations: Elements of StyleEssbase Calculations: Elements of Style
Essbase Calculations: Elements of StyleAlithya
 
Why Integrate using an API? | MuleSoft
Why Integrate using an API? | MuleSoftWhy Integrate using an API? | MuleSoft
Why Integrate using an API? | MuleSoftBui Kiet
 
Vancouver mulesoft meetup
Vancouver mulesoft meetupVancouver mulesoft meetup
Vancouver mulesoft meetupVikalp Bhalia
 
Mule oracle connectors
Mule  oracle connectorsMule  oracle connectors
Mule oracle connectorsD.Rajesh Kumar
 

What's hot (20)

Oracle primavera p6 and ebs projects where do they meet ppt
Oracle primavera p6 and ebs projects   where do they meet pptOracle primavera p6 and ebs projects   where do they meet ppt
Oracle primavera p6 and ebs projects where do they meet ppt
 
Salesforce Cloud Infrastructure and Challenges - A Brief Overview
Salesforce Cloud Infrastructure and Challenges - A Brief OverviewSalesforce Cloud Infrastructure and Challenges - A Brief Overview
Salesforce Cloud Infrastructure and Challenges - A Brief Overview
 
206520 p6 web services programming interface
206520 p6 web services programming interface206520 p6 web services programming interface
206520 p6 web services programming interface
 
Primavera integration possibilities Technical overview - Oracle Primavera Col...
Primavera integration possibilities Technical overview - Oracle Primavera Col...Primavera integration possibilities Technical overview - Oracle Primavera Col...
Primavera integration possibilities Technical overview - Oracle Primavera Col...
 
Integrating primavera p6 with oracle erp which technology path is right for...
Integrating primavera p6 with oracle erp   which technology path is right for...Integrating primavera p6 with oracle erp   which technology path is right for...
Integrating primavera p6 with oracle erp which technology path is right for...
 
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
 
Solving todays problems with oracle integration cloud
Solving todays problems with oracle integration cloudSolving todays problems with oracle integration cloud
Solving todays problems with oracle integration cloud
 
EPM Automate - Automating Enterprise Performance Management Cloud Solutions
EPM Automate - Automating Enterprise Performance Management Cloud SolutionsEPM Automate - Automating Enterprise Performance Management Cloud Solutions
EPM Automate - Automating Enterprise Performance Management Cloud Solutions
 
Oracle Primavera Gateway 15.2 Webcast
Oracle Primavera Gateway 15.2 WebcastOracle Primavera Gateway 15.2 Webcast
Oracle Primavera Gateway 15.2 Webcast
 
FDMEE versus Cloud Data Management - The Real Story
FDMEE versus Cloud Data Management - The Real StoryFDMEE versus Cloud Data Management - The Real Story
FDMEE versus Cloud Data Management - The Real Story
 
Oracle Planning and Budgeting Cloud Service
Oracle Planning and Budgeting Cloud ServiceOracle Planning and Budgeting Cloud Service
Oracle Planning and Budgeting Cloud Service
 
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
 
What's New in Primavera Gateway 16.1
What's New in Primavera Gateway 16.1What's New in Primavera Gateway 16.1
What's New in Primavera Gateway 16.1
 
Interstellar - The Thomas Jefferson Enterprise EPM Cloud Journey
Interstellar - The Thomas Jefferson Enterprise EPM Cloud JourneyInterstellar - The Thomas Jefferson Enterprise EPM Cloud Journey
Interstellar - The Thomas Jefferson Enterprise EPM Cloud Journey
 
Viasat Launches to the Cloud with Oracle Enterprise Data Management
Viasat Launches to the Cloud with Oracle Enterprise Data Management Viasat Launches to the Cloud with Oracle Enterprise Data Management
Viasat Launches to the Cloud with Oracle Enterprise Data Management
 
Essbase Calculations: Elements of Style
Essbase Calculations: Elements of StyleEssbase Calculations: Elements of Style
Essbase Calculations: Elements of Style
 
Why Integrate using an API? | MuleSoft
Why Integrate using an API? | MuleSoftWhy Integrate using an API? | MuleSoft
Why Integrate using an API? | MuleSoft
 
Oracle FCCS: A Deep Dive
Oracle FCCS: A Deep DiveOracle FCCS: A Deep Dive
Oracle FCCS: A Deep Dive
 
Vancouver mulesoft meetup
Vancouver mulesoft meetupVancouver mulesoft meetup
Vancouver mulesoft meetup
 
Mule oracle connectors
Mule  oracle connectorsMule  oracle connectors
Mule oracle connectors
 

Viewers also liked

CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)
CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)
CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)CleverDATA
 
Customers segmentation_responce prediction
Customers segmentation_responce predictionCustomers segmentation_responce prediction
Customers segmentation_responce predictionCleverDATA
 
Prezentacija Stare Pazove
Prezentacija Stare PazovePrezentacija Stare Pazove
Prezentacija Stare Pazovetatjanaveres
 
Take Your Brand From Commodity to Community
Take Your Brand From Commodity to CommunityTake Your Brand From Commodity to Community
Take Your Brand From Commodity to CommunityValeria Maltoni
 
Splunk - универсальная платформа для работы с любыми данными
Splunk - универсальная платформа для работы с любыми даннымиSplunk - универсальная платформа для работы с любыми данными
Splunk - универсальная платформа для работы с любыми даннымиCleverDATA
 
Schneider Electric Data Center Reference Designs
Schneider Electric Data Center Reference DesignsSchneider Electric Data Center Reference Designs
Schneider Electric Data Center Reference DesignsSchneider Electric
 
DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"
DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"
DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"Dakiry
 

Viewers also liked (11)

CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)
CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)
CleverDATA (Denis Reymer) presentation for CNews Forum 2015 (Banking Section)
 
Customers segmentation_responce prediction
Customers segmentation_responce predictionCustomers segmentation_responce prediction
Customers segmentation_responce prediction
 
Prezentacija Stare Pazove
Prezentacija Stare PazovePrezentacija Stare Pazove
Prezentacija Stare Pazove
 
Emontional Intelligence
Emontional IntelligenceEmontional Intelligence
Emontional Intelligence
 
W.H.S White Card
W.H.S White CardW.H.S White Card
W.H.S White Card
 
A.P.E.C Leaders Week 2007
A.P.E.C  Leaders Week 2007A.P.E.C  Leaders Week 2007
A.P.E.C Leaders Week 2007
 
Take Your Brand From Commodity to Community
Take Your Brand From Commodity to CommunityTake Your Brand From Commodity to Community
Take Your Brand From Commodity to Community
 
Splunk - универсальная платформа для работы с любыми данными
Splunk - универсальная платформа для работы с любыми даннымиSplunk - универсальная платформа для работы с любыми данными
Splunk - универсальная платформа для работы с любыми данными
 
Using Apex for REST Integration
Using Apex for REST IntegrationUsing Apex for REST Integration
Using Apex for REST Integration
 
Schneider Electric Data Center Reference Designs
Schneider Electric Data Center Reference DesignsSchneider Electric Data Center Reference Designs
Schneider Electric Data Center Reference Designs
 
DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"
DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"
DaKiRY_BAQ2016_QADay_Денис Геращенко "How we use Zephyr for Jira in e-commerce"
 

Similar to Deep Dive into Salesforce Integrations: Mapping Engines

Intro to AppExchange - Building Composite Apps
Intro to AppExchange - Building Composite AppsIntro to AppExchange - Building Composite Apps
Intro to AppExchange - Building Composite Appsdreamforce2006
 
Informatica cloud Powercenter designer
Informatica cloud Powercenter designerInformatica cloud Powercenter designer
Informatica cloud Powercenter designerRameswara Reddy
 
How We Built the Private AppExchange App (Apex, Visualforce, RWD)
How We Built the Private AppExchange App (Apex, Visualforce, RWD)How We Built the Private AppExchange App (Apex, Visualforce, RWD)
How We Built the Private AppExchange App (Apex, Visualforce, RWD)Salesforce Developers
 
Implementing AutoML Techniques at Salesforce Scale with Matthew Tovbin
Implementing AutoML Techniques at Salesforce Scale with Matthew TovbinImplementing AutoML Techniques at Salesforce Scale with Matthew Tovbin
Implementing AutoML Techniques at Salesforce Scale with Matthew TovbinDatabricks
 
Implementing AutoML Techniques at Salesforce Scale
Implementing AutoML Techniques at Salesforce ScaleImplementing AutoML Techniques at Salesforce Scale
Implementing AutoML Techniques at Salesforce ScaleMatthew Tovbin
 
Making Your Apex and Visualforce Reusable
Making Your Apex and Visualforce ReusableMaking Your Apex and Visualforce Reusable
Making Your Apex and Visualforce ReusableSalesforce Developers
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataPace Integration
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 
Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1Arunkumar Gurav
 
Quickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudQuickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudSalesforce Developers
 
Lightning Component - Components, Actions and Events
Lightning Component - Components, Actions and EventsLightning Component - Components, Actions and Events
Lightning Component - Components, Actions and EventsDurgesh Dhoot
 
Salesforce Summer 14 Release
Salesforce Summer 14 ReleaseSalesforce Summer 14 Release
Salesforce Summer 14 ReleaseJyothylakshmy P.U
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Taking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and BeyondTaking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and BeyondSalesforce Developers
 
Wave Analytics: Developing Predictive Business Intelligence Apps
Wave Analytics: Developing Predictive Business Intelligence AppsWave Analytics: Developing Predictive Business Intelligence Apps
Wave Analytics: Developing Predictive Business Intelligence AppsSalesforce Developers
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce Developers
 
Programming Building Blocks for Admins
Programming Building Blocks for Admins Programming Building Blocks for Admins
Programming Building Blocks for Admins Salesforce Admins
 
Agile data presentation 3 - cambridge
Agile data   presentation 3 - cambridgeAgile data   presentation 3 - cambridge
Agile data presentation 3 - cambridgeRomans Malinovskis
 

Similar to Deep Dive into Salesforce Integrations: Mapping Engines (20)

Intro to AppExchange - Building Composite Apps
Intro to AppExchange - Building Composite AppsIntro to AppExchange - Building Composite Apps
Intro to AppExchange - Building Composite Apps
 
Informatica cloud Powercenter designer
Informatica cloud Powercenter designerInformatica cloud Powercenter designer
Informatica cloud Powercenter designer
 
How We Built the Private AppExchange App (Apex, Visualforce, RWD)
How We Built the Private AppExchange App (Apex, Visualforce, RWD)How We Built the Private AppExchange App (Apex, Visualforce, RWD)
How We Built the Private AppExchange App (Apex, Visualforce, RWD)
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from ppt
 
Implementing AutoML Techniques at Salesforce Scale with Matthew Tovbin
Implementing AutoML Techniques at Salesforce Scale with Matthew TovbinImplementing AutoML Techniques at Salesforce Scale with Matthew Tovbin
Implementing AutoML Techniques at Salesforce Scale with Matthew Tovbin
 
Implementing AutoML Techniques at Salesforce Scale
Implementing AutoML Techniques at Salesforce ScaleImplementing AutoML Techniques at Salesforce Scale
Implementing AutoML Techniques at Salesforce Scale
 
Making Your Apex and Visualforce Reusable
Making Your Apex and Visualforce ReusableMaking Your Apex and Visualforce Reusable
Making Your Apex and Visualforce Reusable
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and OData
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 
ELEVATE Paris
ELEVATE ParisELEVATE Paris
ELEVATE Paris
 
Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1
 
Quickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudQuickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics Cloud
 
Lightning Component - Components, Actions and Events
Lightning Component - Components, Actions and EventsLightning Component - Components, Actions and Events
Lightning Component - Components, Actions and Events
 
Salesforce Summer 14 Release
Salesforce Summer 14 ReleaseSalesforce Summer 14 Release
Salesforce Summer 14 Release
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Taking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and BeyondTaking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and Beyond
 
Wave Analytics: Developing Predictive Business Intelligence Apps
Wave Analytics: Developing Predictive Business Intelligence AppsWave Analytics: Developing Predictive Business Intelligence Apps
Wave Analytics: Developing Predictive Business Intelligence Apps
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmers
 
Programming Building Blocks for Admins
Programming Building Blocks for Admins Programming Building Blocks for Admins
Programming Building Blocks for Admins
 
Agile data presentation 3 - cambridge
Agile data   presentation 3 - cambridgeAgile data   presentation 3 - cambridge
Agile data presentation 3 - cambridge
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Deep Dive into Salesforce Integrations: Mapping Engines

  • 1. Deep dive into Salesforce Integrations: Mapping Engines Salesforce World Tour NYC June 18, 2015
  • 2. Ami Assayag Architect, CRM Science Developer UG Leader, PhillyForce @AmiAssayag Speakers
  • 3. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 4. Agenda • What is a mapping engine? • Architecture overview? • Support infrastructure • Mapping types • Code, code and more code!
  • 5. What is a Mapping Engine? • For the user – User interface that provide flexibility to how the integration interacts with the org. – Allows pre-configuration and changes without development • Beind the scene – Supported by a code that handles outbound and inbound transactions.
  • 6. Why Use Mapping Engines for Integrations? • Allows for more generic integrations • Dynamic – builds callout bodies – Interprets incoming payloads • Changes to external service can be handled without additional development
  • 7. Architecture Overview (Outbound) Salesforce Org External System Mapping Data Callout Handler Inbound Mapping Engine Outbound Mapping Engine Org Data Apex REST Trigger/Job 1 2 3 4 5
  • 8. Architecture Overview (Inbound) Salesforce Org External System Mapping Data Callout Handler Inbound Mapping Engine Outbound Mapping Engine Org Data Apex REST Trigger/Job 12 3 4
  • 9. Pillars of Mapping Engine Code • Use object data type instead of specific types • Cast custom and standard objects to sobject • Build soql queries dynamically • Use DMLOptions
  • 10. Infrastructure Choices • Mapping engines are database driven • Data infrastructure options – Custom objects • Pro: easier to manage relationships • Con: more directly accessible to users – Custom setting • Pro: can be protected, cached • Con: difficult to manage relationships, requires data configuration – Custom Metadata Types • Pro: can include pre-configured data, can be protected, cached • Con : difficult to manage relationships
  • 11. Mapping Data Structure • Important: The integration terminology is the “Master” terminology because Salesforce mapping can be changed. Object Mapping Object Integration Object Salesforce Object Field Mapping Object Integration Object Integration Field Salesforce Field Mapping Type Inbound Outbound Value Mapping Object Integration Field Integration Value Salesforce Value Inbound Outbound
  • 12. Simplified Field Mapping Data Structure • Each field mapping record represents the mapping of a single field between the two systems. Field Mapping Object Integration Object Salesforce Object Integration Field Salesforce Field Mapping Type Inbound Outbound Values Example = prospect = Opportunity = person.first_name = Contact__r.Name = Value = true = true
  • 13. Mapping Types • Regular Value – single value of any acceptable data type • Constant – value that is defined by the mapping, not by the integration • Value Map – sub mapping for value conversion (normally for picklists) • Object – mapping of lookup relationships • Related List – mapping of related list mapping
  • 14. Integration Trigger // Trigger to handle all callouts for the Opportunity object trigger ContactIntegration on Contact(after insert) { ProcessTrigger.sendInsertedRecords('Person', Trigger.newMap.keySet()); } • Pass to static class – Integration object name (not salesforce name) – Triggered record ids (not actual objects because it is not likely to contain all the information needed.
  • 15. Prepare the Field Mapping // property to hold field mappings per object private map<string, list<FieldMapping__c>> fieldMappings; public list<FieldMapping__c> getFieldMappings(string obj) { // make sure the variable is instantiated if (fieldMappings == null) fieldMappings = new map<string, list<FieldMapping__c>>(); // check if the object mappings was already fetched if (fieldMappings.get(obj) == null) { // get the mappings for the object fieldMappings.put(obj, [SELECT Name, SalesforceObject__c, SalesforceField__c, IntegrationField__c, MappingType__c, FROM FieldMapping__c WHERE IntegrationObject__c = :obj AND Incoming__c = true //can make this dynamic LIMIT 1000]); } // return the list of mappings for the requested object return fieldMappings.get(obj); }
  • 16. Re-Query the Triggered Records // prepare a set of strings to hold all the field names (set prevents dups) set<string> fieldsToSelect = new set<string>(); // get the field mapping for the specified object and collect the fields that need to be queried for (FieldMapping__c mapping : getFieldMappings(objectName)) { // exclude related list and constant mapping if (mapping.MappingType__c != 'Related List' && mapping.MappingType__c != ‘Constant') fieldsToSelect.add(mapping.SalesforceField__c); } // start a query string and add the select fields string query = 'SELECT '; for (string fieldToSelect : fieldsToSelect) query += fieldToSelect + ','; // remove the last comma query = query.substring(0, query.length()-1); // add the from and where clause query += ' FROM ' + objectName + ' WHERE Id IN :' + recordIds; // dynamically retrieve records into list of sobject list<sObject> records = database.query(query);
  • 17. Loop Through Records and Mappings // recieve a list of records and create a json body to call the integration public list<map<string, object>> processMapping(string objectName, list<sObject> records) { // define a list of maps that contain value pairs that can be built // dynamically and serialized. // the list represents the array of sent records // each map represents a single record // the map keyset represent the integration field names // the map values represent the field values in sfdc list<map<string, object>> jsonStructure = new list<map<string, object>>(); object fieldValue; // get the records from the database and loop through the records for (sObject record : records) { // prepare a map to hold the value pairs for the current record map<string, object> outboundRecord = new map<string, object>(); // loop through each mapping record for this object for (FieldMapping__c mapping : getFieldMappings(objectName)) { // assemble value pairs } } return jsonStructure ; }
  • 18. While Looping – Get the Value (Simple Value) // check if any of the value need to be accessed through a lookup list<string> FieldParts = fieldName.split('.'); // loop through all the associated objects to drill down to the actual referenced object integer part = 0; while (part < FieldParts.size() - 1) { record = record.getSobject(FieldParts[part]); // go to next node if the record is valued if (record == null) break; else part += 1; } // make sure the record is not null (example: if accountId is null, Account.name will cause a an exception) if (record != null) { // get the value from the record retValue = record.get(FieldParts[part]); // the last part is the field itself, use a simple get to return the value as a string. // if value is null, don't process further (just return null) if (retValue != null) { // figure out the field type and do any conversion required by the integration } } }
  • 19. While Looping – Add Value Pair // split the integration field name - may need to add one or more nested objects before adding a value pair. list<string> node = mapping.IntegrationField__c.split('.'); // prepare a map to hold a parent object. start with the outbound record reference map<string, object> currentObject = outboundRecord; // prepare a map to hold a nested object map<string, object> nestedObject; // loop through the integration nodes in the path and place each nested object/value for (integer i = 0; i < node.size(); i++) { if (i == node.size()-1) { // this is the last node in the path (the value), so add it unless a dependent field is null currentObject.put(node[i], fieldValue); } else { // check if the nested object already exists if (currentObject.containsKey(node[i])) nestedObject = (map<string, object>)(currentObject.get(node[i])); else // if the nested object was not found, instantiate one. nestedObject = new map<string, object>(); // add the nested object to the current object currentObject.put(node[i], nestedObject); // make the nested object the next current object currentObject = nestedObject; } } }
  • 20. Finish the loop and Serialize . . . . // if any field values were added for this record, add it to the // outbound body if (!outboundRecord.isEmpty()) jsonStructure.add(outboundRecord); } // deserialize the list of map so it is ready to be sent. Remove empty objects if (!jsonStructure.isEmpty()) jsonBody = json.serialize(jsonStructure).remove('{}'); // returned the serialized structure return jsonBody;
  • 21. Ami Assayag Architect, CRM Science User Group Leader, PhillyForce @AmiAssayag Q & A
  • 24. While Looping – Get the Value (other types) // only process mappings that are not of type related list if (mapping.MappingType__c == 'Constant') { // this is a string value that is stored in the salesforce field fieldValue = mapping.SalesforceField__c; } else if (mapping.MappingType__c == 'Account' || mapping.MappingType__c == 'Contact') // this is a lookup to a related object // Get the Id and call processMapping recursively to get object’s value pairs; } else { // Single Value or Value map // get the field value from the record fieldValue = retrieveValue(record, mapping.SalesforceField__c); // check if the retrieved value needs to be mapped to other values if (mapping.MappingType__c == 'Value Map') // get the mapped value from the custom setting fieldValue = getValueMapping(mapping.Name.toLowerCase(), string.valueof(fieldValue)); }