To save data shared from DataSync for Salesforce you will need to install and configure the DataSync Agent. There are some custom configurations you will need in the agent.xml file that is created upon installing the DataSync Agent.

To save data to a database as shared out with DataSync for Salesforce, you will need Krypton 8.0.7 and newer for the DataSync Agent and will need to acquire the databases.xml configuration file from Perspectium Support for the Agent to work properly with Salesforce records. Contact Perspectium Support for more information.


To set up the DataSync Agent for Salesforce, follow these steps:


Follow the steps to installing the DataSync Agent and on Step 5 of the setup process where you select the DataSync Type, choose the Manual Configuration (advanced) option from the dropdown.

Locate the agent.xml file in the directory you specified when installing the DataSync Agent. Then, open the agent.xml file in a text editing application.

Use the example agent.xml below to configure data replication from Salesforce to a database. Update the following directives with the information applicable to you per the descriptions in the table below:

DirectiveDescription
<message_connection>

URL for the Perspectium Integration Mesh (MBS) cloud server that you will connect to. You can request this information from Perspectium Support.

queue = Queue name in the Integration Mesh (MBS) where data coming out of Salesforce is shared to

password = Password used to connect to your Integration Mesh (MBS)

user = Username used to connect to your Integration Mesh (MBS)

<decryption_key>
Decryption key to decrypt data synced shared out of Salesforce. This should match the encryption key used to encrypt the data in the Perspectium application in Salesforce
<database_type>

Type of local database you are syncing your Salesforce data to

To see which databases are supported for Salesforce DataSync, see DataSync Agent Supported Databases.

<database_server>
URL for your database. If your database is installed on your local machine, set this value to localhost.
<database_user>
Username used to connect to your database
<database_password>
Password used to connect to your database
<database>
Name of your database
<schema_connection>

URL for your Salesforce organization e.g., https://login.salesforce.com or https://login.salesforce.com/services/oauth2/token 

user = Username used to log into your Salesforce org

password = Password used to log into your Salesforce org

(info) NOTE: If you have issues with the Agent getting authentication failures connecting to Salesforce, check your Salesforce password. Because of how API calls are made to Salesforce to obtain the schema, passwords may have encoding issues with some special characters when calling the API causing it to try an incorrect password. Try updating your password as a troubleshooting step.

client_id = Salesforce Consumer Key for the Perspectium DataSync app

client_secret =Salesforce Consumer Secret for the Perspectium Datasync app

(info) NOTE: You can access your Salesforce Consumer Key and Consumer Secret by navigating to the gear icon Setup > Apps > App Manager > Perspectium DataSync > View.

The Consumer Key and Consumer Secret should be available based on setting up a Connected App in Salesforce when you setup the DataSync for Salesforce application.


Example of agent.xml

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
	<agent>
		<max_reads_per_connect>4000</max_reads_per_connect>
		<polling_interval>30</polling_interval>
	 	<skip_message_set_processing/>
		<subscribe>
			<task>
				<task_name>salesforce</task_name>
 				<message_connection queue="psp.out.replicator.mysalesforce" password="password" user="user">amqp://example.perspectium.net</message_connection>
 				<handler>com.perspectium.replicator.sql.SQLSubscriber</handler>
 				<decryption_key>some_decryption_key_here</decryption_key>
 				<database_type>mysql</database_type>
 				<database_server>localhost</database_server>
 				<database_port>3306</database_port>
 				<database_user>username</database_user>
 				<database_password>password</database_password>
 				<database_params>characterEncoding=UTF-8</database_params>
 				<database>databasename</database>

 				<schema_connection user="your_sfuser@yourcompany.com" password="yourpassword" client_id="yourconsumerkey"  client_secret="yourconsumersecret">https://login.salesforce.com</schema_connection>
 				<primary_key>Id</primary_key>
				<skip_database_creation/>

 				<date_time_format>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</date_time_format>
			</task>
 		</subscribe>
	</agent>
</config>

Move databases.xml into the Agent's conf folder i.e. <Perspectium_DataSync_Agent_Installed_Directory>/conf

This should be the same folder where agent.xml is located that you configured in the previous step.

Then, in databases.xml, you will need to change the following values in the <database_type></database_type> section that corresponds to your target database. For example, if you are sharing to a MySQL database, you would modify the values in the <database_type>mysql</database_typesection:

Old ValueNew Value
<most_recent_record_query>SELECT sys_id FROM %s WHERE sys_id = "%s" AND %s = "%s"</most_recent_record_query><most_recent_record_query>SELECT Id FROM %s WHERE Id = "%s"</most_recent_record_query>

This change is so that the Agent will use the Id field (Salesforce's unique identifier field) to query for records to check if they exist.

Snippet of databases.xml with this change:

<database>
    <database_type>mysql</database_type>   
    .              
	<most_recent_record_query>SELECT Id FROM %s WHERE Id = "%s"</most_recent_record_query>
    .           
 </database>	


Save your changes and follow the instructions to start the DataSync Agent.