SlideShare a Scribd company logo
1 of 20
Generic Package Extension Architecture 
for AppExchange Partners 
Ami Assayag 
Chief Architect 
CRM Science 
@amiassayag 
Kirk Steffke 
Senior Developer 
CRM Science 
@kirkevonphilly
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 any litigation, risks associated with completed and any 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-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These 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.
Ami Assayag 
Chief Architect 
CRM Science
Kirk Steffke 
Senior Developer 
CRM Science
Managed Package Challenges 
Flexibility of platform creates (un)expected variability 
Edition specific features 
• Access and permissions issues 
Optional standard features 
• Person accounts, record types, etc. 
Unknown sharing models 
• Org specific user access 
Varying target org business logic 
• Pre-existing or a-typical business logic
Customer Wants… Customer Gets… 
“...in our org, we do 
<process x> this 
way.” 
“…your package 
does <x>, can it 
do <y>?” 
“…we use <custom object> instead 
of <standard object>“
Extension Package Flow 
Salesforce Org 
Optional Native Base Package Extension Package 
Trigger Trigger 
Trigger Handler 
Business logic Business logic Business logic 
Callout Handler 
External Application
Generic Extension Package Architecture Advantages 
Completely 
generic 
Can handle any 
org-specific 
complexity 
Flexible and 
reusable 
Extends to 
separate packages 
or target orgs
Technologies Used 
The right tools for the job…
Custom Settings 
• Very similar to Custom Objects 
Familiar 
• Can be exposed to or hidden from end-users 
Visibility 
• Won’t count against SOQL limits 
Efficient 
Readily Available 
• Apex 
• Visualforce 
• Formula Fields 
• Web Services API
Interfaces 
// A new global class w/in the Base Package 
global with sharing class <className> { 
} 
// Define an interface with method blueprints 
global interface <interfaceName>{ 
} 
// Define a generic class with generic params 
<returnType> <methodName(<parameters>);
Dynamic Instantiation of Classes 
// get the type of the class outside the package that impl. the generic interface 
Type t = Type.forName(<namespace>, <className>); 
// use a concrete type of the intf. To create a new inst. of the ext. impl. 
Extension ExtensionClass = (Extension)t.newInstance();
Code Examples - Outbound 
3 Steps to Implement this Design Pattern
Step 1: Create Interface in the Base Package 
// A new global class w/in the Base Package 
global with sharing class BasePackage { 
} 
// Define an interface with method blueprints 
global interface Extension { 
} 
// Define a generic class with generic params 
object GenericMethod(list<object> params);
Step 2: Create External Class 
public with sharing class MyExtension implements BasePackageNameSpace.BasePackage.Extension { 
// define a the generic class that is present in the interface 
public static object GenericMethod(list<object> params) { 
// replace input params with variables that have concrete types. 
set<id> RecordIds = (set<id>)params[0]; 
string somestring = (string)params[1]; 
// use the concrete type variables to call the class that does all the work 
ProcessFutureCallout(RecordIds, somestring); 
// in this example the business logic needs to make a callout to a different API 
@future(callout = true) 
public static void ProcessFutureCallout(set<id> RecordIds, string somestring) { 
// anything inside this class can be custom 
} 
// in this case there is no need to return anything so return null; 
return null; 
} 
}
Step 3: Call External Class from Within the Base Package 
// Get the external class name from a custom setting 
PackageExtension__c ext = PackageExtension__c.getInstance('extensionName'); 
if (ext == null) { 
else { 
// Get the type of the class outside the package that implements the generic interface 
Type t = Type.forName(ext.Namespace__c, ext.ClassName__c); 
// Using a concrete type of the int., create a new instance of the ext. implementation 
BasePackage.Extension ExtensionClass = (BasePackage.Extension)t.newInstance(); 
// Use ExtensionClass to call the generic method with any relevant variable 
list<object> retList = ExtensionClass.GenericMethod( 
new list<object>{someRecordIds, someString} 
); 
} 
// Process normal business logic 
}
Code Examples - Inbound 
Re-using Common Code from the Base Package
Utilize Base Package Code from the Extension 
// Define a global entry point to the package that can be called from outside the package 
global object CallMethod(string classDotMethod, list<object> params) { 
// Instantiate a generic object to return 
object retValue; 
// Using a Base Package Class' internal public static method with parameters 
else if (classDotMethod == 'BasePackageClass2.Method1') 
BasePackageClass2.Method1( 
(set<Id>)params[0], 
(string)params[1], 
(string)params[2] 
); 
// Return methods results to caller as an object 
return retValue; 
} 
// Using a Base Package Class' internal public static method 
if (classDotMethod == 'BasePackageClass1.Method1') 
retValue = BasePackageClass1.Method1();
Generic Package Extension Architecture 
for AppExchange Partners 
Ami Assayag 
Chief Architect 
CRM Science 
@amiassayag 
Kirk Steffke 
Senior Developer 
CRM Science 
@kirkevonphilly

More Related Content

Similar to CRM Science - Dreamforce '14: Generic Package Extension Architecture for AppExchange Partners

Similar to CRM Science - Dreamforce '14: Generic Package Extension Architecture for AppExchange Partners (20)

Partition Your (Apex) Trigger Logic Using Metadata
Partition Your  (Apex) Trigger Logic Using MetadataPartition Your  (Apex) Trigger Logic Using Metadata
Partition Your (Apex) Trigger Logic Using Metadata
 
Salesforce DX with Visual Studio Code
Salesforce DX with Visual Studio CodeSalesforce DX with Visual Studio Code
Salesforce DX with Visual Studio Code
 
Quit Jesting and Test your Lightning Web Components, Phillipe Ozil
Quit Jesting and Test your Lightning Web Components, Phillipe OzilQuit Jesting and Test your Lightning Web Components, Phillipe Ozil
Quit Jesting and Test your Lightning Web Components, Phillipe Ozil
 
Understanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoUnderstanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We Do
 
Orchestrate all of your salesforce automation with the trigger actions framework
Orchestrate all of your salesforce automation with the trigger actions frameworkOrchestrate all of your salesforce automation with the trigger actions framework
Orchestrate all of your salesforce automation with the trigger actions framework
 
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreDeveloping Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events Handlers
 
Secure Salesforce: CRUD / FLS / Sharing
Secure Salesforce: CRUD / FLS / SharingSecure Salesforce: CRUD / FLS / Sharing
Secure Salesforce: CRUD / FLS / Sharing
 
Bug Hunting with the Salesforce Developer Console
Bug Hunting with the Salesforce Developer ConsoleBug Hunting with the Salesforce Developer Console
Bug Hunting with the Salesforce Developer Console
 
Finding Security Issues Fast!
Finding Security Issues Fast!Finding Security Issues Fast!
Finding Security Issues Fast!
 
Visualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsVisualforce Hack for Junction Objects
Visualforce Hack for Junction Objects
 
Intro to Apex Programmers
Intro to Apex ProgrammersIntro to Apex Programmers
Intro to Apex Programmers
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmers
 
Dreamforce 2017: Salesforce DX - an Admin's Perspective
Dreamforce 2017:  Salesforce DX - an Admin's PerspectiveDreamforce 2017:  Salesforce DX - an Admin's Perspective
Dreamforce 2017: Salesforce DX - an Admin's Perspective
 
Automating the Elastic Stack
Automating the Elastic StackAutomating the Elastic Stack
Automating the Elastic Stack
 
Next-level integration with Spring Data Elasticsearch
Next-level integration with Spring Data ElasticsearchNext-level integration with Spring Data Elasticsearch
Next-level integration with Spring Data Elasticsearch
 
Salesforce Developer Group Toronto - Winter'19
Salesforce Developer Group Toronto - Winter'19Salesforce Developer Group Toronto - Winter'19
Salesforce Developer Group Toronto - Winter'19
 
Secure Development on the Salesforce Platform - Part I
Secure Development on the Salesforce Platform - Part ISecure Development on the Salesforce Platform - Part I
Secure Development on the Salesforce Platform - Part I
 
Understanding Multitenancy and the Architecture of the Salesforce Platform
Understanding Multitenancy and the Architecture of the Salesforce PlatformUnderstanding Multitenancy and the Architecture of the Salesforce Platform
Understanding Multitenancy and the Architecture of the Salesforce Platform
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.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...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

CRM Science - Dreamforce '14: Generic Package Extension Architecture for AppExchange Partners

  • 1. Generic Package Extension Architecture for AppExchange Partners Ami Assayag Chief Architect CRM Science @amiassayag Kirk Steffke Senior Developer CRM Science @kirkevonphilly
  • 2. 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 any litigation, risks associated with completed and any 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-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These 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.
  • 3. Ami Assayag Chief Architect CRM Science
  • 4. Kirk Steffke Senior Developer CRM Science
  • 5. Managed Package Challenges Flexibility of platform creates (un)expected variability Edition specific features • Access and permissions issues Optional standard features • Person accounts, record types, etc. Unknown sharing models • Org specific user access Varying target org business logic • Pre-existing or a-typical business logic
  • 6. Customer Wants… Customer Gets… “...in our org, we do <process x> this way.” “…your package does <x>, can it do <y>?” “…we use <custom object> instead of <standard object>“
  • 7. Extension Package Flow Salesforce Org Optional Native Base Package Extension Package Trigger Trigger Trigger Handler Business logic Business logic Business logic Callout Handler External Application
  • 8. Generic Extension Package Architecture Advantages Completely generic Can handle any org-specific complexity Flexible and reusable Extends to separate packages or target orgs
  • 9. Technologies Used The right tools for the job…
  • 10. Custom Settings • Very similar to Custom Objects Familiar • Can be exposed to or hidden from end-users Visibility • Won’t count against SOQL limits Efficient Readily Available • Apex • Visualforce • Formula Fields • Web Services API
  • 11. Interfaces // A new global class w/in the Base Package global with sharing class <className> { } // Define an interface with method blueprints global interface <interfaceName>{ } // Define a generic class with generic params <returnType> <methodName(<parameters>);
  • 12. Dynamic Instantiation of Classes // get the type of the class outside the package that impl. the generic interface Type t = Type.forName(<namespace>, <className>); // use a concrete type of the intf. To create a new inst. of the ext. impl. Extension ExtensionClass = (Extension)t.newInstance();
  • 13. Code Examples - Outbound 3 Steps to Implement this Design Pattern
  • 14. Step 1: Create Interface in the Base Package // A new global class w/in the Base Package global with sharing class BasePackage { } // Define an interface with method blueprints global interface Extension { } // Define a generic class with generic params object GenericMethod(list<object> params);
  • 15. Step 2: Create External Class public with sharing class MyExtension implements BasePackageNameSpace.BasePackage.Extension { // define a the generic class that is present in the interface public static object GenericMethod(list<object> params) { // replace input params with variables that have concrete types. set<id> RecordIds = (set<id>)params[0]; string somestring = (string)params[1]; // use the concrete type variables to call the class that does all the work ProcessFutureCallout(RecordIds, somestring); // in this example the business logic needs to make a callout to a different API @future(callout = true) public static void ProcessFutureCallout(set<id> RecordIds, string somestring) { // anything inside this class can be custom } // in this case there is no need to return anything so return null; return null; } }
  • 16. Step 3: Call External Class from Within the Base Package // Get the external class name from a custom setting PackageExtension__c ext = PackageExtension__c.getInstance('extensionName'); if (ext == null) { else { // Get the type of the class outside the package that implements the generic interface Type t = Type.forName(ext.Namespace__c, ext.ClassName__c); // Using a concrete type of the int., create a new instance of the ext. implementation BasePackage.Extension ExtensionClass = (BasePackage.Extension)t.newInstance(); // Use ExtensionClass to call the generic method with any relevant variable list<object> retList = ExtensionClass.GenericMethod( new list<object>{someRecordIds, someString} ); } // Process normal business logic }
  • 17. Code Examples - Inbound Re-using Common Code from the Base Package
  • 18. Utilize Base Package Code from the Extension // Define a global entry point to the package that can be called from outside the package global object CallMethod(string classDotMethod, list<object> params) { // Instantiate a generic object to return object retValue; // Using a Base Package Class' internal public static method with parameters else if (classDotMethod == 'BasePackageClass2.Method1') BasePackageClass2.Method1( (set<Id>)params[0], (string)params[1], (string)params[2] ); // Return methods results to caller as an object return retValue; } // Using a Base Package Class' internal public static method if (classDotMethod == 'BasePackageClass1.Method1') retValue = BasePackageClass1.Method1();
  • 19.
  • 20. Generic Package Extension Architecture for AppExchange Partners Ami Assayag Chief Architect CRM Science @amiassayag Kirk Steffke Senior Developer CRM Science @kirkevonphilly