Friday, September 29, 2023
HomeProductsDelphi DACDeveloping applications with Salesforce CRM integration in Delphi

Developing applications with Salesforce CRM integration in Delphi

Cloud-based CRM systems are becoming incredibly popular in these days. This trend is quite clear. The usage of cloud services does not require a deployment and costly specialized software domestic support, which ultimately reduces a company’s total expenses.

Despite the flexibility and ease of use, it is often necessary to work directly with data stored in the cloud, without using the original Web interfaces or custom APIs. It can be any analytical studies, statistical data processing or creating certain forms of reporting documentation. In this case, a developer will find it more convenient to work with such data using familiar tools. The popular development tool – Embarcadero RAD Studio is no exception here. Various APIs and different access methods to Cloud CRM data can significantly complicate this process, as in most cases, they are not universal. Here comes ODBC technology to help, providing a standard interface to access any databases, including clouds. UniDAC components allow working in Delphi with any ODBC driver. For this UniDAC includes a special component: TODBCUniProvider. Let’s see how to work with data stored in one of the most popular CRM systems – Salesforce. First, you need to install and configure any ODBC driver working with Salesforce. For example, Devart ODBC Driver for Salesforce. As an example, let’s create a small application that implements a master-detail connection between two standard Salesforce objects: Account and Opportunity. Account will be represented by master dataset and Opportunity by detail dataset. The AccountId field will be used for communication between the entities.

The order of actions will be as follows:

1. Download and install ODBC Driver for Salesforce.

2. Configure the installed driver to work with the existing Salesforce account. You can find the detailed instruction here. Before using the datasource name “Devart Salesforce Driver” created at this stage, you can check its setting with the help of the “Test connection” button.

3. Open IDE and create a small project, containing the following components:

4. To work with ODBC driver, configure TUniConnection as follows:

uses ODBCUniProvider;
  UniConnection.ProviderName := 'ODBC';
  UniConnection.Server := 'Devart Salesforce Driver';

In this case in the UniConnection.Server property we specified DSN, created in Step 2. Note that you can also work with a required ODBC driver, using UniConnection without explicitly specifying DSN. To do this, you should fill the appropriate parameters in the ConnectString property. To work with Devart ODBC Driver for Salesforce, this property will look as follows:

UniConnection.ConnectString := 'Provider Name=ODBC;Server="DRIVER={Devart ODBC Driver for Salesforce};Data;User ID=;Password=;Security Token="';

5. Compose necessary SQL queries:

AccountQuery.SQL.Text := 'Select Id, Name, BillingStreet, BillingState, WebSite From Account';
OpportunityQuery.SQL.Text := 'Select Name, StageName, Amount, Type, Description From Opportunity Where AccountId = :Id';

Note that in both queries we did not use all the fields of the Account and Opportunity objects, but only those, which are needed for the demonstration. In addition, to implement the master-detail connection, we added the appropriate Where clause.

6. Configure a master-detail relationship between the queries:

AccountDataSource.DataSet := AccountQuery;
OpportunityDataSource.DataSet := OpportunityQuery;
OpportunityQuery.MasterSource := AccountDataSource;

7. Open the queries to obtain the required result.


8. On the screenshot below you can see the obtained work result.

Thus, we were able to implement the specified task. We have seen that working with cloud CRM data in Delphi using ODBC provider is as simple as using traditional DBs. Similarly, you can work with data of any system, having a necessary driver. Devart offers a whole range of such ODBC drivers. Moreover, this list is constantly updated, thereby expanding end users opportunities to work with a variety of data.

Here is the code source:



    • Hello, Rex Chan!
      We will consider a possibility of adding this functionality in UniDAC in the future.

  1. I know delphi Enterprise version plus include in future delphi version. I hope you can including Unidca or new product line due to i use delphi XE5 prof.
    I dream my next delphi project will Excel addon with integration.

Comments are closed.