Try WSO2 Cloud for Free
Sign in

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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Next »

Problem

When your organization creates new accounts in Salesforce, you might want to create the same account in Microsoft Dynamics CRM as well.

Solution

In this guide, we explain how to use the Salesforce REST connector to get details of your new accounts (e.g., Id, name) from Salesforce and add them to Microsoft Dynamics CRM using the Microsoft dynamics CRM connector. If in case of a failure, we se nd an email alert to the relevant stakeholders using the Gmail connector.

How the solution works

The following diagram illustrates how the basic solution works:

  • Get the account details from Salesforce using the query operation (poll using scheduled tasks).
  • Add the account details to Microsoft Dynamics CRM using the createEntity operation.

The following diagram illustrates how we send an email alert to the users if in case of a failure. Sending email alerts is optional. You can enable it by setting the gmail_alert_to_user property to true. You set up a database to store the timestamp of records. Based on this timestamp, failed records are created in Microsoft Dynamics CRM in the next trigger and the information of lost data is sent to given email addresses.

  • Send an email to managers using the Gmail connector's sendMail operation.

Before you begin, follow the guides below to set up Microsoft Dynamics CRM, Salesforce, and Gmail:

Let's get started.

  1. Go to WSO2 Cloud and sign up if you haven't done so already. The UI guides you through the sign-up process.
  2. Sign in to WSO2 Cloud and select the Integration Cloud from the list of Clouds that are available.
  3. The Integration Cloud opens. Click CREATE APPLICATION.
  4. Click WSO2 ESB Composite Application.
  5. Select the Local File System option and click Continue.
  6. Give an application name (e.g., SalesforceToMsDynamics) and upload this CAR file.

    What is a CAR file? A Composite Application (CAR) is an archive file that has the collection of artifacts that you want to deploy in a WSO2 product instance. These artifacts are usually JAVA-based or XML configurations, designed differently for each product in the WSO2 Carbon platform. You can deploy these artifacts to generate services.

  7. You link to the Salesforce and the Microsoft Dynamics CRM accounts that you use in this scenario using environment variables. Download this file and change the values of the variables according to your requirements.

     Click here to read more information about the environment variables used in this file...

    {

    "salesforcerest_accessToken" : "00D7F000001bgeT!ARkAQMIj3BLrLwW74YIY8cP50SKAWc3k",
    "salesforcerest_apiUrl" : "https://ap5.salesforce.com",
    "salesforcerest_apiVersion" : "v32.0",
    "salesforcerest_hostName" : "https://login.salesforce.com",
    "salesforcerest_clientSecret" : "##############",
    "salesforcerest_clientId" : "#############################",
    "salesforcerest_refreshToken" : "5A613hy0tHCYdhxrWr6MmIbH3FIe4l4lFddmjfLo.K1aIgVEfrgfrACD59HVcUdJzdwefewfewfHI6WyI",
    "salesforcerest_registryPath" : "connectors/salesforcerest",
    "msdynamics365_apiUrl" : "https://wso2438.crm5.dynamics.com",
    "msdynamics365_accessToken": VlMTAiXX0.bTyWq4NznbAbJqpBKQ6PotrzR6UPxIGHEc95Lr13VGquEyf4HNdOCA",
    "msdynamics365_refreshToken" : "AQABAAAAAAA9kTklhVy7SJTGAzR-VStVQG3uxgpqTvz8_dA6VrUgAA",
    "msdynamics365_apiVersion" : "v8.2",
    "msdynamics365_resource" : "https://wso2438.crm5.dynamics.com/",
    "msdynamics365_clientSecret" : "te576hyjhjk/MkEotJsF8MIleWQdEovHBoprpH9I=",
    "msdynamics365_clientId" : "2972350d-yuio-4614-9ac1-detreyhu",
    "task_interval_time" : "120"
    }

    If you wanted to send an email alert in case of a failure, set the gmail_alert_to_user property to true and specify the following environment variables:

    {
    "gmail_alert_to_user" : "true",
    "gmail_to" : "kana@gmail.com",
    "gmail_from" : "XYZ@gmail.com",
    "gmail_userId" : "priyakules@gmail.com",
    "gmail_accessToken" : "ya29.GlvGBJDbA27tW9f9yyvosfZGL68EYAqi5i_ROMwS7QcI0",
    "gmail_apiUrl" : "https://www.googleapis.com/gmail",
    "gmail_clientId" : "822314599637-7duq8l2.apps.googleusercontent.com",
    "gmail_clientSecret" : "yZbHNaM3O1laa8FA6_3Phbaj",
    "gmail_refreshToken" : "1/tvfRH9edFtVylT_AsI4_E98cI9wUbbDuSBhR6Ih4dFU"
    }

    Here's a description of all the properties:

      • salesforcerest_accessToken: Access token from the Salesforce account.
      • salesforcerest_apiUrl: The apiUrl to access the salesforce REST API.
      • salesforcerest_apiVersion: The version of the Salesforce REST API.
      • salesforcerest_hostName: The SalesforceOAuth endpoint when issuing authentication requests in your application.
      • task_interval_time: The interval time of the scheduled task in seconds. The default is 120 seconds. 
      • salesforcerest_clientSecret: The value of the client secret that you get when registering your application with Salesforce.
      • salesforcerest_clientId: The value of the client ID that you get when registering your application with Salesforce.
      • salesforcerest_refreshToken: The value of your client secret that you obtain at the Google developer console.
      • salesforcerest_registryPath: The registry path of the connector where the values are stored. You must give the value as connectors/<value>.
      • msdynamics365_apiUrl: The API URL of the Microsoft Dynamics 365 Web API.
      • msdynamics365_accessToken: The access token used to access the Microsoft Dynamics 365 Web API via request.
      • msdynamics365_apiVersion: The API version of the Microsoft Dynamics 365 (v8.2).
      • msdynamics365_refreshToken: An OAuth 2.0 refresh token. The application can use this token to acquire other access tokens after the current one expires.
      • msdynamics365_resource: The App ID URI of the web API (e.g., https://kavi859.crm5.dynamics.com/ ).
      • msdynamics365_clientSecret:  The secret key of the application that is registered in the Azure AD.
      • msdynamics365_clientId:  The client ID of the client application that is registered in Azure AD.
      • gmail_userId: User's mail ID.
      • gmail_accessToken: The access token used to access the Gmail REST API.
      • gmail_apiUrl: The API URL of Gmail (https://www.googleapis.com/gmail).
      • gmail_clientId: The client ID that you get when registering your application with the Gmail API.
      • gmail_clientSecret: The client-secret that you get when registering your application with the Gmail API.
      • gmail_refreshToken: The refresh token that is used to get a new access token when the previous token has expired.
      • gmail_to: The email address of the stakeholder to whom an email alert will be sent in case of a failure.
      • gmail_from: The email address of the sender .
      • gmail_alert_to_user: Optional. If this value is set to true, an email alert will be sent to the stakeholders if in case of a failure.
  8. Click the  Advanced Setting...  link, expand the  Environment Variables  section, and upload the JSON file that you created in the previous step.
  9. Click the Create button at the end of the form to complete creating the application.
  10. Note that you see the application's Overview page once the application is deployed in the Cloud.
     
    You have now created an application in WSO2 Integration Cloud. Let's see how to test the scenario

  11. Go to Salesforce and create a new account (say First Test Account).
     

  12. Go to Microsoft Dynamics CRM and find a new account entity by the name of the Salesforce account that you created earlier.
     

You have now used the WSO2 connectors in the connector store to create Account Entity in Microsoft Dynamics CRM with Salesforce Accounts details.

Want to customize the default scenario?

In this guide, you tried the solution on WSO2 Integration Cloud. You can do the same on-premise, with your own WSO2 Enterprise Integrator instance. For informatoin on modifying the default scenario, see Modify the Default Integration Scenario.

  • No labels