本篇参考:https://resources.docs.salesforce.com/sfdc/pdf/integration_patterns_and_practices.pdfhtml
Salesforce实时访问外部数据。这样就不须要在Salesforce中保存数据,而后在Salesforce和外部系统之间协调数据。web
一.上下文api
您可使用Salesforce跟踪销售线索、管理销售渠道、建立销售机会,并捕获将销售线索转换为客户的订单详细信息。然而,Salesforce不是包含或处理订单的系统。订单由外部(远程)系统管理。可是销售表明但愿在Salesforce中查看和更新实时订单信息,而没必要学习和使用外部系统。浏览器
二. 问题和考虑因素框架
问题: 在Salesforce中,如何查看、搜索和修改存储在Salesforce外部的数据,而不将数据从外部系统移动到Salesforce中?ide
考虑因素:当基于这种模式应用解决方案时,须要考虑各类各样的因素:工具
•是否要在Salesforce中构建声明式/点击式出站集成或UI mashup?布局
•是否有大量数据而且不想复制到Salesforce组织中?学习
•是否须要同时访问少许远程系统数据?大数据
•是否须要实时访问最新数据?
•是否将数据存储在云端或后台系统中,但但愿在Salesforce组织中显示或处理这些数据?
•在Salesforce中存储某些类型的数据时,您是否有数据驻留问题?
三. 解决方案
解决方案 |
适配程度 |
介绍 |
Salesforce Connect |
Best |
使用Salesforce Connect访问来自外部源的数据以及Salesforce数据。实时从传统系统(如SAP、Microsoft和Oracle)中提取数据,而无需在Salesforce中复制数据。Salesforce Connect将外部系统中的数据表映射到组织中的外部对象。外部对象与自定义对象相似,只是它们映射到Salesforce组织外部的数据。Salesforce Connect使用到外部数据的实时链接来始终保持外部对象的最新状态。
访问外部对象从外部系统实时获取数据。Salesforce Connect容许您:
•查询外部系统中的数据。 •在外部系统中建立、更新和删除数据。 •经过列表视图、详细信息页、记录提要、自定义选项卡和页面布局访问外部对象。 •定义外部对象与标准或自定义对象之间的关系,以集成不一样来源的数据。 •在外部对象页面上启用Chatter提要以进行协做。 •对外部数据运行报告(有限)。 •查看Salesforce移动应用程序上的数据。 要使用Salesforce Connect访问存储在外部系统上的数据,可使用如下适配器之一: •OData 2.0适配器或OData 4.0适配器-链接到任何OData 2.0或4.0生产商公开的数据。 •跨组织适配器-链接到存储在另外一个Salesforce组织中的数据。跨组织适配器使用标准的Lightning Platform REST API。与OData不一样,跨组织适配器直接链接到另外一个组织,而不须要中间web服务。 •经过Apex建立的自定义适配器-若是OData和跨组织适配器不适合您的须要,请使用Apex链接器框架开发您本身的适配器。 也能够参考: |
Request and Reply |
Suboptimal |
使用Salesforce web服务API发出特殊数据请求以访问和更新外部系统数据。此解决方案包括如下方法:
使用Salesforce SOAP API。自定义Visualforce页面或按钮以同步方式启动Apex SOAP调用。在Salesforce中,您可使用WSDL并生成最终的代理Apex类。此类提供调用远程服务所需的逻辑。Visualforce页上用户启动的操做而后调用Apex控制器操做,该操做执行此代理Apex类以执行远程调用。Visualforce页面须要定制Salesforce应用程序。
使用Salesforce REST API。自定义Visualforce页面或按钮以同步方式启动Apex HTTP调用(REST服务)。在Salesforce中,可使用标准的GET、POST、PUT和DELETE方法调用HTTP服务。可使用几个HTTP类与RESTful服务集成。Visualforce页上用户启动的操做而后调用Apex控制器操做,该操做执行这些代理Apex类以执行远程调用。Visualforce页面须要定制Salesforce应用程序。
这种操做适用于特殊场景,须要过滤或者须要作数据的格式转换等操做,之因此次优由于须要有沟通、开发以及联调的工做,耗时长,稳定性取决于代码质量等等。 |
四. 流程草图
在这种状况下:
1.浏览器执行一个AJAX调用,该调用依次对相应的外部对象适配器执行一个操做。
2.适配器将操做转换为OData请求,并经过集成层和服务层向远程系统发出HTTP GET请求。
3.远程系统经过集成层和服务层向Salesforce返回JSON响应。
4.将响应从OData转换为外部对象并呈现回浏览器。
五. 其余关键点
调用机制 |
描述 |
External Objects |
Salesforce Connect将Salesforce外部对象映射到外部系统中的数据表。Salesforce Connect不是将数据复制到组织中,而是按需实时访问数据。即便数据存储在组织外部,Salesforce Connect也能与Lightning平台无缝集成。Salesforce工具可使用外部对象,例如全局搜索、查找关系、记录源和Salesforce移动应用程序。外部对象也可用于Apex、SOSL、SOQL查询、salesforceapi,以及经过元数据API、变动集和包进行部署。 |
Lighting Components or Visualforce Pages |
当远程进程做为涉及用户界面的端到端进程的一部分触发时使用,而且结果必须在Salesforce记录中显示或更新。例如,向外部支付网关提交信用卡支付并当即返回显示给用户的支付结果的过程。由用户界面事件触发的集成一般须要建立自定义Lightning组件或Visualforce页面。 |
六. 常见考题
Given the diagram below, a Salesforce org, middleware, and Historical data store (with 20milIion records and growing) exists with connectivity between them.
Historical records are archived from Salesforce and moved to Historical Data store (which houses 20M records and growing; fine tuned to be performant with search queries). Call center agents use Salesforce, when reviewing occasional special cases, have requested access to view the related historical case items that relate to submitted cases. Which mechanism and patterns are recommended to maximize declarative configuration?
Use ESB tool with Data Virtualization pattern, expose OData endpoint, and then use Salesforce Connect to consume and display the External Object along side with the Case object.
Universal Containers (UC) wants to connect their on-premise ERP system to view Order data in Salesforce. UC is considering a solution to integrate the on-premise system using Salesforce Connect via OData. Which three considerations should an Architect keep in mind when recommending use of Salesforce Connect? Salesforce Connect的优势
Customer wants the ability to query external data using Global Search and reports.
Customer needs to query small amounts of data at any time and display using a related list.
Customer has a large amount of data that they do not want to load into Salesforce.
Customer does not want real-time access to the ERP data and is willing to wait for hourly refreshes.
Customer wants to create a master-detail relationship between Opportunity and the external object.
总结:此种场景针对大数据不能落在SF而且知足须要查看等的需求,仍是很好的解决方案。至此全部的集成模式都已经描述完。篇中有错误欢迎指出,有不懂欢迎留言。