【DataModel】Get started with the Salesforce datamodel

# Introduction #
Sharperlight also provides a datamodel for Salesforce, so this time I would like to create a simple report using that datamodel.

Salesforce is a cloud-based customer relationship management (CRM) software. Sharperlight uses a datamodel for Salesforce to interact with its API and synchronize cloud data with a locally prepared database, enabling reporting tailored to individual needs.

# Downloading the Datamodel #
The Salesforce datamodel can be downloaded from the [Sharperlight](https://www.sharperlight.com/) website. Access it via the top menu by navigating to **Resources** -> **Datamodels**.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/7c3b3722-d94e-e89f-e651-fe229cb6e626.png)
A list of datamodels developed and provided by Sharperlight will be displayed. From that list, we can download the datamodel for Salesforce.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/fb5f75e2-0590-1074-28a5-b43bede6d8c1.png)

# Installing the Datamodel #
From here on, I will assume that Sharperlight is already installed.

Close all Sharperlight applications, including the Sharperlight service. Launch the Sharperlight application menu and select the `Datamodel Installer`.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/3c997595-a50b-13e9-2bf7-b067d94269f6.png)

Once the `Datamodel Installer` is launched, use the "Add" button to include the datamodel we downloaded earlier.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/8c7d4a4f-37d8-df3a-2e57-7fe39ddd25f4.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/22dab32a-e831-e416-0978-ac02d1ca3323.png)
Finish the installation by clicking the `Finish` button. At the same time, the datamodel will be compiled automatically.

# Preparing the Database #
Prepare an empty database in Microsoft SQL Server.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/fa4a9db5-ea32-eaaf-740f-b37df5ee3d63.png)

# Connecting the Datamodel to the Database #
Use the `Client Setup` in Sharperlight to define the connection between the Salesforce datamodel and the prepared database for synchronization.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/c5f62469-5363-d22f-3360-a3815bf931fa.png)
In this case, database server authentication was used.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/11db6a1c-c4cb-fcb0-7d36-170575355626.png)
Finally, confirm the connection by clicking the `Test` button. Finish the `Client Setup` by clicking the `OK` button.

# Configuring API Connection Information #
Next, set up the connection information for Sharperlight to communicate with the Salesforce API.

First, ensure that API access is enabled on the Salesforce side. This will allow us to obtain key information such as the `Consumer Key` and `Consumer Secret`.
Using the `Site Setup` in Sharperlight, enter the obtained key information.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/b9cfac02-1e99-4879-95d4-5f62166b822a.png)

Select **Salesforce** from the product settings, and the properties to enter the key information will be displayed on the right side. It should look like this:
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/4e9888c5-a657-f336-4422-af084dc77f38.png)
Once the settings are complete, save by clicking the `Close` button.

# Starting the Synchronization #
Now that the preparation for data synchronization with Salesforce is complete, let's start the synchronization by launching the Sharperlight service.

### Starting the Sharperlight Service ###
Select `Services` from the Sharperlight application menu to launch it.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/631b0126-8be7-f80e-01a7-e5bc3466a5d8.png)

Alternatively, we can start the Sharperlight service from the Windows Services.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/e9ea664f-6da8-bc35-bb95-1e62e67717bc.png)

### Using the Salesforce Synchronization Web Interface ###
From the Sharperlight application menu, select `Solutions`.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/da87f388-08ca-b4e0-3aa1-094db68caa8c.png)

Once the solution is launched, double-click on `Sharperlight SalesForce UI`.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/ce1801aa-fa5d-aa05-b25e-1867f00a595d.png)

A page will appear in the browser to manage synchronization and other tasks.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/ee9eaa21-58eb-da3f-c801-173727fddcec.png)

### Starting the Synchronization Process ###
From the management page's top menu, select `System` -> `Sync Settings`. 

Click the **Execute Sync Now** button to start the synchronization.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/23618f00-1423-a278-42ad-6547cf721db0.png)

Once the synchronization starts, the screen will switch to the Sync Stats page. After a while, we will see the processing history in the Process Progress list at the bottom of the screen.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/55913acf-54df-be9e-0ead-22d75037382a.png)

As the synchronization process continues...
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/a6f92888-3bcd-d735-83e2-08e54c912976.png)

When the synchronization is complete, we will see a display like this:
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/a842248c-38f8-c738-05ec-efe398998aea.png)

# Data Verification and Reporting #
To verify the synchronized data, select `Dashboard` from the top menu of the management page. We should see the data displayed. Note that my Salesforce environment is a demo for development, so the data is limited.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/4b5543ba-b322-ac5d-dc91-bb35f25e868d.png)
This is a collection of reports prepared by Sharperlight, but we can create reports tailored to our needs using Sharperlight's publish queries or the Excel add-in.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/e7d73291-8ccc-a1a3-57c9-b5094be16230.png)

Additionally, the synchronization process can be scheduled, allowing us to execute it at a specific time every day to keep the synchronized database up-to-date. In the web UI, we can specify the execution time here.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/ea549997-5a95-663a-39cb-56be8c3e5ef5.png)

If we want to make more detailed settings, we can do so in the Sharperlight scheduler.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/ec0f73d8-a478-8b47-a25a-e310bfd04682.png)

# Conclusion #
We have explored data synchronization and reporting using the Salesforce datamodel. Once we set up the data synchronization, we can leverage Sharperlight's powerful reporting capabilities to create reports tailored to our specific business needs.