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

The underlying use case of the Export Salesforce Leads to Google Spreadsheet scenario is that you get details of your new leads' accounts from Salesforce, add that information to a Google spreadsheet, and then send an email alert regarding the lead creation to the relevant stakeholders. This section explains how to modify this default scenario as follows:

  • Change the information that you retrieve from Salesforce about new leads.
  • Edit the default email template that you send to stakeholders regarding new leads.
  • Change the default time duration of the scheduled task that checks whether new leads have come.

Let's get started.

Open the project's artifacts

  1. Download and install WSO2 EI tooling.

  2. Download this ZIP file to your machine and unzip it.

  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  SalesforceLeadsToGoogleProject 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.

    • Salesforce

    • Google Spreadsheet

    • 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 SalesforceLeadsToGoogleProject in the left navigation and note that the project's artifacts open in the tooling interface as follows:

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

    Tip: See Working with sequences for information about sequences.

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

    "SELECT id, firstname, lastname, company, Email, CreatedDate FROM Lead WHERE CreatedDate > 'LastTime'"

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

  4. To change the default email template, go to the design view, click the Script mediator, and change the following script body. 

    var mail = mc.getProperty("");
    			    var id = mc.getProperty("");
    			    var fname = mc.getProperty("salesforce.lead.firstname");
    			    var lname = mc.getProperty("salesforce.lead.lastname");  
    			    var createdDate = mc.getProperty("salesforce.lead.createdDate");                                
                    var fields = "[[";                         
                    if(mail !="" && mail !=null && id !="" && id !=null && fname !="" && fname !=null && lname !="" && lname !=null){
                    fields = fields.concat('"' + id + '","' + mail + '","' + fname + '","' + lname + '","' + createdDate + '"');
                    fields = fields.concat("]]");

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

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

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

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

  6. Once you are done modifying the default scenario, right click GithubToSpreadsheetCAPP and click Export Composite Application Project. You will then be promped to save the project's artifacts as a CAR file.

You have now modified the default scenario.

  • No labels