Try WSO2 Cloud for Free
Sign in

All docs This doc
||
Skip to end of metadata
Go to start of metadata

The underlying use case of the Export Salesforce Account Details to Microsoft Dynamics CRM scenario is that you get details of your new accounts in Salesforce and add them to Microsoft Dynamics CRM. This  section explains how to modify this default scenario as follows:

  • Change the information that you retrieve from Salesforce about new accounts.
  • Change the default time duration for the scheduled task that checks whether new accounts are created.
  • Edit the default email template that you send to stakeholders in case of a failure.
  • Retrieve the data that were created after a timestamp that you mention. You can set any timestamp in the past to see data that might have been lost due to a failure in the system.

Let's get started.

  1. Download and install WSO2 EI tooling. 

  2. Download the content of this GitHub location to a suitable location in your machine.

  3. Open the EI tooling interface. The workspace is any folder in your local file system where your tooling artifacts will be saved. For example,

  4. Once the workspace opens, click the File -> Import menu from the menu bar and then under the General drop-down, click Existing Projects into Workspace.
  5. Select the source folder that you downloaded earlier in step 2 as the root directory, select all the projects inside the directory, and click Finish.

    Let's import the required connectors to the project.
  6. Right click SalesforceToMsDynamics and click Add or Remove Connector.

  7. Select Add connector and click Next.
  8. Connect to the WSO2 Store using the Connector store location option and select the following connectors from the list once the available connectors load.

    • SalesforceRest

    • Microsoft Dynamics 365

    • Gmail

You have now created a tooling project using the downloaded artifacts. Next, let's modify the artifacts to our requirements.

Modify the project's artifacts

  1. Expand SalesforceToMsDynamics in the left navigation and Note that the project's artifacts open in the tooling interface as follows:

  2. Open the sequence sampleRequest.xml under synapse-config -> sequences.

    Tip: See Working with sequences for information about sequences.

  3. To change the information that you retrieve from Salesforce about new accounts, go to the Source tab and modify the salesforce query given below:

    "SELECT id, name, CreatedDate FROM Account WHERE CreatedDate > 'LastTime'"

    Tip: For more information about salesforce.query, see Querying records.

  4. To change the default email template, go to the Source tab of sampleRequest.xml and modify the following code as you want. 

     <property expression="fn:concat('The data ',$ctx:salesforce.account.name, ' is lost in this trigger and which will be captured in next trigger')" name="gmail.contentBody"/>
    <gmail.sendMail configKey="gm_init">
         <to>{$ctx:gmail.to}</to>
         <subject>Alert About Data Lost</subject>
         <from>{$ctx:gmail.from}</from>
         <messageBody>{$ctx:gmail.contentBody}</messageBody>
         <contentType>text/html; charset=UTF-8</contentType>
    </gmail.sendMail>

    By default, we have set the scheduled task to fetch new accounts from Salesforce in every 120 seconds. This is done for testing purposes. But, in a real business environment, you might want to increase this value.

  5. To change the time duration of the scheduled task, open the SalesforceToMsDynamics.xml file that is under synapse-config -> tasks and change the value of the Interval property. 

    Tip: If you change the schedule task time here, be sure to change the task_interval_time property with the same value in environment variables also.

    Tip: For more information on scheduled tasks, see creating a scheduled task.

  6. To get all the issues that are created after a timestamp that you specify, create a mysql database to store the timestamp. 

    There is a scheduled task that polls Salesforce and collects data that is created after a timestamp value that is in the database. After each poll, the sceduled task updates the timestamp value to the current time so that the next time it polls, it will retreive only the newer data. However, you might sometimes want to see old data that might be lost due to a system failure. 

     Click here for information on how to create a database to store the timestamp...

    You can create a database and store the timestamp value in it. The timestamp is in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

    1. Log in to WSO2 Integration Cloud by going to http://wso2.com/cloud/, clicking the Sign In link and then selecting WSO2 Integration Cloud.
    2. The Integration Cloud opens. Click CREATE DATABASE.
    3. Enter the following information in the form that opens, scroll down, and click Create Database.
      • Database NamesalesforceToMsdynamics
      • Default User Name: admin
      • Give a suitable password

    4. The database that you just created opens on the console. Copy the database name, URL, and username. 

      Tip

      You see additional characters in the database name and username because the Integration Cloud adds them to uniquely identify the tenant of the database and the user.

    5. Assuming you already have MySQL Server installed in your local environment, go to the command-line or terminal, type mysql and press enter to go to the MySQL prompt, and then execute the following commands to connect to the MySQL database that you just created.
      The following commands are an example. You can change the database name, table name, column name and Timestamp value as you want.

      SQL Commands
      mysql -u  admin_L4WrEC-F -h mysql.storage.cloud.wso2.com -p 
      use salesforceToMsdynamics_ac1125;
      create table registry (Timestamp VARCHAR(40));
      INSERT INTO registry (Timestamp) VALUES("2017-08-22T04:02:59.169Z");
      UPDATE registry SET Timestamp = '2017-08-22T06:55:52Z';
  7. Back in the Tooling interface, open the sequence sampleRequest.xml that is under synapse-config -> sequences and replace its code with this code.

  8. Modify the following code blocks in your code with your mysql credentials, database URL, driver, table name, and column name.

    <dblookup>    
       <connection>
            <pool>
                <password>root</password>
                <user>admin_L4WrEC-F</user>
                <url>jdbc:mysql://mysql.storage.cloud.wso2.com:3306/salesforceToMsdynamics_ac1125?useSSL=false</url>
                <driver>com.mysql.jdbc.Driver</driver>
                <property name="autocommit" value="false"/>
            </pool>
        </connection>
        <statement>
            <sql><![CDATA[select Timestamp from registry]]></sql>
            <result column="Timestamp" name="registryTimestamp"/>
        </statement>
    </dblookup>
    <dbreport> 
     <connection>
        <pool>
             <password>root</password>
             <user>admin_L4WrEC-F</user>
             <url>jdbc:mysql://mysql.storage.cloud.wso2.com:3306/salesforceToMsdynamics_ac1125?useSSL=false</url>
             <driver>com.mysql.jdbc.Driver</driver>
             <property name="autocommit" value="false"/>
        </pool>
     </connection>
     <statement>
        <sql><![CDATA[UPDATE registry SET Timestamp = ?]]></sql>
        <parameter expression="$ctx:newsystemTime" type="VARCHAR"/>
     </statement>
    </dbreport>
  9. Once you are done modifying the default scenario, right click SalesforceToMsDynamics and click Export Composite Application Project. You will then be promped to save the project's artifacts as a CAR file.

  • No labels