How to Develope Apps With Salesforce CRM Integration in Delphi
It;s often necessary to work directly with data stored in the cloud without using original web interfaces or custom APIs. Let’s create a small application as an example.
Join the DZone community and get the full member experience.
Join For FreeCloud-based CRM systems are becoming incredibly popular in these days. This trend is quite clear. The use of cloud services does not require deployment or costly specialized software domestic support that ultimately reduce a company’s total expenses.
Despite flexibility and ease of use, it is often necessary to work directly with data stored in the cloud without using 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 using familiar tools. Various APIs and different access methods to Cloud CRM data can significantly complicate this process because in most cases, they are not universal. ODBC technology can provide a standard interface to access any databases, including the cloud.
UniDAC components allow you to work in Delphi with any ODBC driver. For this, UniDAC includes a special component: TODBCUniProvider
. Let’s see how to work with data stored in 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 a master dataset and Opportunity
, by a 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
This is pretty straightforward.
2. Configure It to Work With the Salesforce Account
You can find the detailed instruction here. Before using the datasource named Devart Salesforce Driver
created at this stage, you can check its setting with the help of the Test connection button.
3. Create a Project
Open IDE and create a small project containing the following components:
4. Configuration
To work with the 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, which we 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 Source=login.salesforce.com;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 needed for the demonstration. In addition, to implement the master-detail
connection, we added the appropriate Where
clause.
6. Configure a Query Relationship
Configure a master-detail relationship between the queries:
AccountDataSource.DataSet := AccountQuery;
OpportunityDataSource.DataSet := OpportunityQuery;
OpportunityQuery.MasterSource := AccountDataSource;
7. Open the Queries
Open the queries to obtain the required result:
AccountQuery.Open;
OpportunityQuery.Open;
8. See the Results
In the screenshot below, you can see the obtained work result.
We were able to implement the specified task. We have seen that working with cloud CRM data in Delphi is as simple as using traditional DBs. Similarly, you can work with data of any system with the necessary driver. Devart offers a whole range of such ODBC drivers. This list is constantly updated, allowing end users opportunities to work with a variety of data.
Published at DZone with permission of Jordan Sanders. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments