Contact Us 1-800-596-4880

Salesforce Einstein Analytics Connector

Support Category: Select

Anypoint Connector for Salesforce Analytics Cloud (Salesforce Analytics Cloud Connector) enables you to connect to the Salesforce Analytics Cloud application using the Salesforce External Data API. The connector exposes convenient methods for creating and populating data sets into the Salesforce Analytics Cloud system. Load data into the Analytics Cloud from many different data sources whether they are on-premises or in the cloud. Go beyond .csv files with this connector.

Read through this User Guide to understand how to set up and configure a basic integration flow using the connector. Read through the Technical Reference to understand how the connector operations tie in with the External Data API calls.

Before You Begin

This document assumes you are familiar with Mule, Anypoint Connectors, and Anypoint Studio.

To use Salesforce Analytics Cloud Connector you must have a Salesforce account and necessary permissions for uploading data into Analytics Cloud. For more information see Analytics Cloud External Data API Developer’s Guide.

Compatibility

Application/Service Version

Mule Runtime

3.5.0 and later

External Data API

43.0

Install the Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for the connector and click Install.

  4. Follow the prompts to install the connector.

Use the Connector

To use the Salesforce Analytics Cloud connector in a Mule application project:

  1. In Studio, select File > New > Mule Project.

  2. Enter a name for your new project and leave the remaining options with their default values.

  3. If you plan to use Git, select Create a .gitignore file for the project with the default .gitignore settings for Studio Projects, and then click Next.

  4. Click Finish to create the project.

You can use Salesforce Analytics Cloud Connector as an outbound connector in your flow to push data into Salesforce Analytics Cloud system. To use it as an outbound connector, simply place the connector in your flow at any point after an inbound endpoint. Note that you can also use the Salesforce Analytics Cloud connector in a batch process to push data to Salesforce Analytics Cloud system in batches.

Configure a Global Element

  1. Click the Global Elements tab at the base of the canvas.

  2. On the Global Mule Configuration Elements screen, click Create.

  3. In the Choose Global Type wizard, filter by salesforce analytics, expand Connector Configuration, and select one of the four available configurations depending on your needs. See Connector Authentication.

    salesforce analytics create global element
  4. Click Ok.

  5. Enter the global element properties:

    For all the configurations, the Proxy fields are:

    Field Description

    Host

    Host name of the proxy server. If this is not set then no proxy is used.

    Port

    The port number on which the proxy server runs.

    Username

    The username to log in to the server. If this is not set, then no authentication is used.

    Password

    The username to log in to the server.

Connector Authentication

To access the data in a Salesforce Analytics Cloud instance, you have the following possibilities in terms of authentication:

Studio 6 Choice Described Here

Salesforce Analytics Cloud: Basic Authentication

Basic Authentication

Salesforce Analytics Cloud: Salesforce Analytics Cloud (OAuth)

OAuth 2.0 Web Flow

Salesforce Analytics Cloud: OAuth 2.0 JWT Bearer

OAuth 2.0 JWT Bearer

Salesforce Analytics Cloud: OAuth 2.0 SAML Bearer

OAuth 2.0 SAML Bearer

Basic authentication is the easiest to implement. All you need to do is provide your credentials in a global configuration, then reference the global configuration in any Salesforce Analytics Cloud connector in your application. Basic authentication is generally recommended for internal applications.

Implementing OAuth 2.0-related authentication mechanisms, involves a few extra steps, but may be preferred if your service is exposed to external users, as it ensures better security. More technical information on these authentication mechanisms at the following links: Basic Auth, OAuth 2.0 Web Flow, OAuth 2.0 SAML Bearer and OAuth 2.0 JWT Bearer.

Basic Authentication

salesforce analytics basic authentication config
In the image above, the placeholder values refer to a configuration file placed in the src folder of your project (Learn how to configure properties). You can either hardcode your credentials into the global configuration properties, or reference a configuration file that contains these values. For simpler maintenance and better reusability of your project, it is recommended that you use a configuration file. Keeping these values in a separate file is useful if you need to deploy to different environments, such as production, development, and QA, where your access credentials differ. See Deploying to Multiple Environments for instructions on how to manage this.
Field Description

Name

Enter a name for this connector to reference it later.

Username

Enter a Salesforce Analytics Cloud username.

Password

Enter the corresponding password.

Security token

Enter the Security Token for the username.

NOTE: Do not confuse the Security Token required in Basic Authentication with the one required in OAuth authentication. Here, the token refers to your user, not to your application, as it does in OAuth.

Read timeout

Specifies the amount of time, in milliseconds, that the consumer will wait for a response before it times out. Default value is 0 which means infinite.

Connection timeout

Specifies the amount of time, in milliseconds, that the consumer attempts to establish a connection before it times out. Default value is 0 which means infinite.

Enable Data Sense

When enabled, DataSense extracts metadata for Salesforce Analytics Cloud objects to automatically determine the data type and format that your application must deliver to, or can expect from Salesforce Analytics Cloud system. By enabling this functionality, Mule discovers the type of data you must send to, or receive from Salesforce Analytics.

Metadata file name

Enter the path for the file that contains the descriptions of the object structure of the row that is uploaded into Salesforce Analytics Cloud. This path has to be relative to the src/main/resources directory. It can also be a wildcard for example metadata/*.json and it takes all the files ending in .json.

OAuth 2.0 Web Flow

On the General tab, configure the following fields:

salesforce analytics oauth authentication config
Field Description

Name

Enter a name for this connector to reference it later.

Consumer Key

Enter the consumer key for your connected app from Salesforce.

Consumer Secret

Enter the consumer secret for your connected app from Salesforce.

On No Token

Select the action that the connector must take if it finds no access token.

Read timeout

Specifies the amount of time, in milliseconds, that the consumer waits for a response before it times out. Default value is 0 which means infinite.

Connection timeout

Specifies the amount of time, in milliseconds, that the consumer attempts to establish a connection before it times out. Default value is 0 which means infinite.

Enable Data Sense

When enabled, DataSense extracts metadata for Salesforce Analytics Cloud objects to automatically determine the data type and format that your application must deliver to, or can expect from Salesforce Analytics Cloud system. By enabling this functionality, Mule discovers the type of data you must send to, or receive from Salesforce Analytics.

Metadata file name

Enter the path for the file that contains the descriptions of the object structure of the row that is uploaded into the Salesforce Analytics Cloud system. This path has to be relative to the src/main/resources directory.

For more information on how to create connected apps see Creating a Connected App.

On the OAuth tab, configure the following fields:

salesforce analytics oauth authentication oauthtab
Field Description

Domain

Enter the domain name to use as the callback endpoint. The domain name is not a full URL, but a domain name, IP address, or a hostname.

Local Port

Enter the local port to use for the callback endpoint.

Remote Port

Enter the remote port to use to build the callback URL.

Path

Enter the path to use for the callback endpoint.

HTTP Connector Reference

Enter the HTTP connector reference to use for the callback endpoint.

Default Access Token Id

Enter the Mule Expression to use as an access token.

Object Store Reference

Enter the name of the Object Store reference.

OAuth 2.0 JWT Bearer

salesforce analytics oauth jwt bearer config
Field Description

Consumer key

Enter the consumer key for your connected app from Salesforce.

Key store

Enter the path to a Java key store file used to sign the JWT. The path should be relative to the src/main/resources folder. See Generate a Keystore File.

Store password

Enter the password for the above provided key store.

Principal

Enter the username of the user that you are going to take action of behalf of.

Token endpoint

Enter the URL to server providing the token. For more info see: Understanding OAuth Endpoints.

Read timeout

Specifies the amount of time, in milliseconds, that the consumer will wait for a response before it times out. Default value is 0 which means infinite.

Connection timeout

Specifies the amount of time, in milliseconds, that the consumer attempts to establish a connection before it times out. Default value is 0 which means infinite.

Enable Data Sense

When enabled, DataSense extracts metadata for Salesforce Analytics Cloud objects to automatically determine the data type and format that your application must deliver to, or can expect from Salesforce Analytics Cloud system. By enabling this functionality, Mule discovers the type of data you must send to, or receive from Salesforce Analytics.

Metadata file name

Enter the path for the file that contains the descriptions of the object structure of the row that is uploaded into the Salesforce Analytics Cloud system. This path has to be relative to the src/main/resources directory.

OAuth 2.0 SAML Bearer

salesforce analytics oauth saml bearer config
Field Description

Consumer key

Enter the consumer key for your connected app from Salesforce.

Key store

Enter the path to a Java key store file used to sign the JWT. The path should be relative to the src/main/resources folder. See Generate a Keystore File.

Store password

Enter the password for the above provided key store.

Principal

Enter the username of the user that you are going to take action of behalf of.

Token endpoint

Enter the URL to the server providing the token. For more info see: Understanding OAuth Endpoints.

Read timeout

Specifies the amount of time, in milliseconds, that the consumer will wait for a response before it times out. Default value is 0 which means wait indefinitely.

Connection timeout

Specifies the amount of time, in milliseconds, that the consumer attempts to establish a connection before it times out. The default value is 0, which means wait indefinitely.

Enable Data Sense

When enabled, DataSense extracts metadata for Salesforce Analytics Cloud objects to automatically determine the data type and format that your application must deliver to, or can expect from Salesforce Analytics Cloud system. By enabling this functionality, Mule discovers the type of data you must send to, or receive from Salesforce Analytics.

Metadata file name

Enter the path for the file that contains the descriptions of the object structure of the row that is uploaded into the Salesforce Analytics Cloud system. This path has to be relative to the src/main/resources directory.

Generate a Keystore File

  1. Go to your Mule workspace, and open the command prompt (for Windows) or Terminal (for Mac).

  2. Type keytool -genkeypair -alias salesforce-cert -keyalg RSA -keystore salesforce-cert.jks and press enter.

    Enter the following details:

    • Password for the key store.

    • Your first name and last name.

    • Your organization unit.

    • Name of your City, State, and the two letters code of your country.

  3. The system generates a Java keystore file containing a private and public key pair in your workspace. You need to provide a file path for the keystore in your connector configuration.

  4. Type keytool -exportcert -alias salesforce-cert -file salesforce-cert.crt -keystore salesforce-cert.jks and press enter.

  5. The system now exports the public key from the keystore into the workspace. This is the public key that you need to enter in your Salesforce instance.

  6. Make sure that you have both the key store (salesforce-cert.jks) and the public key (salesforce-cert.crt) files in your workspace.

Examples

The following are the common use cases for the Salesforce Analytics Cloud connector:

  1. Create a data set in the Salesforce Analytics Cloud system, upload data into the data set from an input file, and trigger the system to start processing the data. Use this when dealing with smaller files, preferably less than 10 MB.

  2. Create a data set in the Salesforce Analytics Cloud system, read the data from an input file and split it into batches, upload batches of data into the data set, and trigger the system to start processing the data. We recommend ingesting huge volumes of Data using this approach. Make sure that your batch commit size is less than or equal to 10 MB for optimal performance. The connector throws a warning if the batch commit size is greater than 10 MB.

In version 2.4.0 a retry mechanism was added to the following operations: Upload External Data, Upload External Data Into New Data Set And Start Processing and Create Data Set. The Number of retries parameter was added to each operation in the Advanced tab with a default value of 5.

Example 1: Add the Salesforce Analytics Cloud Connector to a Flow

  1. Create a new Mule project in Anypoint Studio.

  2. Drag the Salesforce Analytics Cloud connector onto the canvas, then select it to open the properties editor.

  3. Configure the connector’s parameters:

    salesforce analytics operation config
    Field Description

    Display Name

    Enter a unique label for the connector in your application.

    Connector Configuration

    Select a global Salesforce Analytics connector element from the drop-drown.

    Operation

    Select an operation for the connector to perform.

  4. Save your configuration.

Example 1: Configure with the Studio Visual Editor

Create a dataset and upload data into it by processing all the data in one big chunk.

Create a new Mule Project by clicking File > New > Mule Project. In the new project dialog box, the only thing you are required to enter is the name of the project. Click Finish.

salesforce analytics new project dialog

Now let’s create the flow. Navigate through the project’s structure and double-click src/main/app/project-name.xml and follow the steps below:

  1. On the right side of Studio search for File.

    salesforce analytics search for file
  2. Drag the File element onto the canvas.

  3. Search for Transform message and drag it after File.

  4. Search for Salesforce Analytics Cloud and drag it after Transform Message.

  5. After completing the previous steps you should see:

    salesforce analytics all flow unconfigured
  6. Let’s start configuring each element. Double-click the File element.

    salesforce analytics file component
  7. Click …​ next to the Path field.

  8. Choose a folder with only the csv file that you want to upload. You can download our example file and save it into chosen folder.

  9. Double-click Salesforce Analytics Cloud connector.

  10. Click the plus sign next to the Connector configuration dropdown.

    salesforce analytics create data set config
  11. A pop-up appears asking for type of configuration. Choose Salesforce Analytics Cloud: Basic Authentication option and click OK.

  12. A new pop-up appears asking for information required for basic authentication. For more info see the Installing and Configuring section

    salesforce analytics basic authentication config
  13. In the Connection section enter the credentials used to access the Salesforce instance.

  14. In the DataSense metadata section for the Metadata file name field enter the filename that describes the data structure you are going to upload. The filename has to be relative to the src/main/resources directory of your Studio project. For the file provided a few steps earlier (CsvDemoTestData.csv) you can use the metadata file provided below but do not forget to copy it into the src/main/resources directory.

  15. Click OK to return to the Salesforce Analytics Cloud tab.

  16. From the Operation dropdown in the Basic Settings section choose Upload external data into new data set and start processing.

  17. From the Operation dropdown in the DataSet info section choose OVERWRITE.

  18. In the Description enter Test data set.

  19. In the Label field under DataSet info enter Test data set.

  20. In the Name field under DataSet info enter test_data_set.

  21. Double-click the Transform message element and add the following mapping in the output section.

    %dw 1.0
    %output application/java
    ---
    payload map ((payload01 , indexOfPayload01) -> {
    	(Id: (trim payload01.Id) as :number) when payload01.Id? and ((trim payload01.Id) != ''),
    	(Country: trim payload01.Country) when payload01.Country? and ((trim payload01.Country) != ''),
    	(City: trim payload01.City) when payload01.City? and ((trim payload01.City) != ''),
    	(Year: (trim payload01.Year) as :number) when payload01.Year? and ((trim payload01.Year) != ''),
    	(Distance: (trim payload01.Distance) as :number) when payload01.Distance? and ((trim payload01.Distance) != ''),
    	(Currencies: ((trim payload01.Currencies) splitBy ";") as :array)
    	when payload01.Currencies? and ((trim payload01.Currencies) != ''),
    	(CreationDate: (trim payload01.CreationDate) as :date{format: "yyyy/MM/dd"})
    	when payload01.CreationDate? and ((trim payload01.CreationDate) != '')
    })
  22. It should look something like the following.

    salesforce analytics all transform message
  23. Now everything is set up and the application can be deployed.

It’s time to test the app. Run the app in Anypoint Studio (right-click the project name and click Run as > Mule Application). Monitor the studio console and check the Salesforce Wave Analytics UI to see if the data was uploaded.

Example 2: Configure with the Studio Visual Editor

Create a dataset and upload data into it by processing the data in several chunks.

When using the batch component tune it based on the amount of memory that you provide to the Mule server. Bear in mind that default threading profile uses 16 threads and each thread is loading data in chunks of 100 records until it reaches the "Commit size" set on "Batch Commit" component. You can minimize the memory used by decreasing the number of threads. Finally you have to be aware of the fact that "Salesforce Analytics Cloud Connector" is also using some memory internally and you should tune "Commit Size" in order to find a good balance but do not set it too low because this will make it inefficient.

Create a new Mule Project by clicking File > New > Mule Project. In the new project dialog box, the only thing you are required to enter is the name of the project. Click Finish.

salesforce analytics new project dialog

Create the flow. Navigate through the project’s structure and double click src/main/app/project-name.xml and follow the steps below:

  1. On the right side of Studio search for Batch.

    salesforce analytics search for batch
  2. Select Batch and drag it onto the canvas.

    salesforce analytics batch component
  3. Similar to what was done in step 1, search for File.

  4. Drag File into the Input section of the batch element created earlier.

  5. Search for Message Enricher and drag it after File.

  6. Search for Transform Message and drag it after Message Enricher.

  7. Search for Salesforce Analytics Cloud and drag it into Message Enricher.

  8. Search for Batch commit and drag it into the Batch step section of Batch.

  9. Search for Salesforce Analytics Cloud and drag it into the Batch commit section of Batch step.

  10. Drag another Salesforce Analytics Cloud connector into the On complete section of Batch.

  11. After completing all the above steps you should see:

    salesforce analytics batch flow unconfigured
  12. Configure each element. Double click the File element.

    salesforce analytics file component
  13. Click …​ next to the Path field.

  14. Choose a folder with only the csv file that you want to upload. You can download our example file and save it into your chosen folder.

  15. Double-click the Salesforce Analytics Cloud connector in the Message Enricher.

  16. Click the plus sign next to the Connector configuration dropdown.

    salesforce analytics create data set config
  17. A pop-up asking for type of configuration appears. Choose the Salesforce Analytics Cloud: Basic Authentication option and click OK.

  18. A new pop-up asks for information required for basic authentication. For more info see the Installing and Configuring section

    salesforce analytics basic authentication config
  19. In the Connection section enter the credentials used to access the Salesforce instance.

  20. In the DataSense metadata section for the Metadata file name field enter the filename that describes the data structure you are going to upload. The filename has to be relative to the src/main/resources directory of your Studio project. For the file provided a few steps earlier (CsvDemoTestData.csv) you can use the metadata file provided below, but do not forget to copy it into the src/main/resources directory.

  21. Click OK to return to the Salesforce Analytics Cloud tab.

  22. From the Operation dropdown in the Basic Settings section choose Create data set.

  23. From the Operation dropdown in the DataSet info section choose OVERWRITE.

  24. In the Description field enter Test data set.

  25. In the Label field under DataSet info enter Test data set.

  26. In the Name field under DataSet info enter test_data_set.

  27. Double-click Message Enricher and fill in the fields as below.

    salesforce analytics message enricher config
  28. Double-click Batch commit from Batch step.

  29. For Commit size enter the number of records you want to process in one step. (for example, 5000)

    The application logs a warning message if the data provided for processing in one step exceeds the size of data accepted by Analytics Cloud System. The message looks like this: "The size of data provided for processing in one step exceeded the maximum size of one chunk allowed by Analytics Cloud System. To optimize the memory used you should decrease the size of data provided in one step.". If you see this message then you should tune the Commit Size by decreasing it until you do not see the message anymore.
  30. Double-click Salesforce Analytics Cloud from Batch commit.

  31. From the Connector configuration dropdown choose Salesforce_Analytics_Cloud__Basic_authentication (only this option should be available).

  32. Choose Upload external data as the operation.

  33. Check the bottom corner on the right-hand side and wait for DataSense to fetch metadata.

    salesforce analytics fetch metadata bar
  34. For Data Set Id enter #[variable:dataSetId]

  35. Double-click the Transform message element and add the following mapping in the output section.

    %dw 1.0
    %output application/java
    ---
    payload map ((payload01 , indexOfPayload01) -> {
    	(Id: (trim payload01.Id) as :number) when payload01.Id? and ((trim payload01.Id) != ''),
    	(Country: trim payload01.Country) when payload01.Country? and ((trim payload01.Country) != ''),
    	(City: trim payload01.City) when payload01.City? and ((trim payload01.City) != ''),
    	(Year: (trim payload01.Year) as :number) when payload01.Year? and ((trim payload01.Year) != ''),
    	(Distance: (trim payload01.Distance) as :number) when payload01.Distance? and ((trim payload01.Distance) != ''),
    	(Currencies: ((trim payload01.Currencies) splitBy ";") as :array)
    	when payload01.Currencies? and ((trim payload01.Currencies) != ''),
    	(CreationDate: (trim payload01.CreationDate) as :date{format: "yyyy/MM/dd"})
    	when payload01.CreationDate? and ((trim payload01.CreationDate) != '')
    })]
  36. It should look something like the following.

    salesforce analytics batch transform message
  37. Double-click Salesforce Analytics Cloud from the On complete section of Batch.

  38. From the Connector configuration dropdown select Salesforce_Analytics_Cloud__Basic_authentication (only this option should be available).

  39. From the Operation dropdown select Start data processing.

  40. In the Data Set ID field, enter #[variable:dataSetId].

  41. At this point, everything should be set up and the application can be deployed.

It is time to test the application. Run the application in Anypoint Studio (Right click the project name in Studio’s package explorer and select Run as > Mule Application). Monitor the studio console and check Salesforce Wave Analytics UI to see if the data was uploaded.

Example 2: Configure in the XML Editor

  1. Add the sfdc-analytics namespace to the mule element as follows:

    xmlns:sfdc-analytics="http://www.mulesoft.org/schema/mule/sfdc-analytics"
  2. Add the location of the analytics schema referred to by the sfdc-analytics namespace:

    http://www.mulesoft.org/schema/mule/sfdc-analytics http://www.mulesoft.org/schema/mule/sfdc-analytics/current/mule-sfdc-analytics.xsd
  3. Add the dw namespace as follows:

    xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
  4. Add location of dw schema referred by dw namespace with the following value:

    http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
  5. Add a context:property-placeholder element to your project, then configure its attributes as follows:

    <context:property-placeholder location="mule-app.properties"/>
  6. Add a sfdc-analytics:config element to your project, then configure its attributes as follows:

    <sfdc-analytics:config name="Salesforce_Analytics_Cloud__Basic_authentication" username="${salesforce.username}" password="${salesforce.password}" securityToken="${salesforce.securityToken}" metadataFileName="${metadata.file.analytics}" doc:name="Salesforce Analytics Cloud: Basic authentication" url="${salesforce.url}"/>
  7. Add an empty flow element to your project as follows:

    <flow name="analytics_performanceFlow">
    </flow>
  8. Within the flow element add a file:inbound-endpoint element as follows:

    <file:inbound-endpoint path="path_to_folder_to_monitor" moveToDirectory="path_to_folder_where_to_move_processed_files" responseTimeout="10000" doc:name="File">
    </file:inbound-endpoint>
  9. Within the flow element add a transform-message element as follows:

    <dw:transform-message doc:name="Transform Message">
                    <dw:set-payload><![CDATA[%dw 1.0
    %output application/java
    ---
    payload map ((payload01 , indexOfPayload01) -> {
    	(Id: (trim payload01.Id) as :number) when payload01.Id? and ((trim payload01.Id) != ''),
    	(Country: trim payload01.Country) when payload01.Country? and ((trim payload01.Country) != ''),
    	(City: trim payload01.City) when payload01.City? and ((trim payload01.City) != ''),
    	(Year: (trim payload01.Year) as :number) when payload01.Year? and ((trim payload01.Year) != ''),
    	(Distance: (trim payload01.Distance) as :number) when payload01.Distance? and ((trim payload01.Distance) != ''),
    	(Currencies: ((trim payload01.Currencies) splitBy ";") as :array)
    	when payload01.Currencies? and ((trim payload01.Currencies) != ''),
    	(CreationDate: (trim payload01.CreationDate) as :date{format: "yyyy/MM/dd"})
    	when payload01.CreationDate? and ((trim payload01.CreationDate) != '')
    })]]></dw:set-payload>
                </dw:transform-message>
  10. Within the flow element add a sfdc-analytics:upload-external-data-into-new-data-set-and-start-processing element as follows:

    <sfdc-analytics:upload-external-data-into-new-data-set-and-start-processing
    	config-ref="Salesforce_Analytics_Cloud__Basic_authentication1"
    	type="recordId"
    	operation="UPSERT"
    	description="Test upload of 2500 records all in one step"
    	label="records_2500_in_one_step"
    	dataSetName="records_2500_in_one_step_with_app"
    	edgemartContainer="TestContainer"
    	notificationSent="ALWAYS"
    	notificationEmail="name@email.com" doc:name="Salesforce Analytics Cloud">
        <sfdc-analytics:payload ref="#[payload]"/>
    </sfdc-analytics:upload-external-data-into-new-data-set-and-start-processing>
  11. In the end the XML file should look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <mule xmlns:sfdc-analytics="http://www.mulesoft.org/schema/mule/sfdc-analytics"
    xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
    xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file
    http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-current.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-current.xsd
    http://www.mulesoft.org/schema/mule/core
    http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/ee/dw
    http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
    http://www.mulesoft.org/schema/mule/sfdc-analytics
    http://www.mulesoft.org/schema/mule/sfdc-analytics/current/mule-sfdc-analytics.xsd">
    	<context:property-placeholder location="mule-app.properties"/>
    	<sfdc-analytics:config
    		name="Salesforce_Analytics_Cloud__Basic_authentication"
    		username="${salesforce.username}"
    		password="${salesforce.password}"
    		securityToken="${salesforce.securityToken}"
    		metadataFileName="${metadata.file.analytics}"
    		doc:name="Salesforce Analytics Cloud: Basic authentication"
    		url="${salesforce.url}"/>
    	<file:connector name="File" autoDelete="true" streaming="true"
    	    validateConnections="true" doc:name="File"/>
    	<flow name="analytics_performanceFlow">
            <file:inbound-endpoint path="path_to_folder_to_monitor"
            moveToDirectory="path_to_folder_where_to_move_processed_files"
            responseTimeout="10000" doc:name="File">
            </file:inbound-endpoint>
            <dw:transform-message doc:name="Transform Message">
                <dw:set-payload><![CDATA[%dw 1.0
    %output application/java
    ---
    payload map ((payload01 , indexOfPayload01) -> {
    
    	(Country: trim payload01.Country) when payload01.Country? and ((trim payload01.Country) != ''),
    
    	(City: trim payload01.City) when payload01.City? and ((trim payload01.City) != ''),
    
    	(Year: (trim payload01.Year) as :number) when payload01.Year? and ((trim payload01.Year) != ''),
    
    	(Distance: (trim payload01.Distance) as :number) when payload01.Distance? and ((trim payload01.Distance) != ''),
    
    	(Currencies: ((trim payload01.Currencies) splitBy ";") as :array)
    	when payload01.Currencies? and ((trim payload01.Currencies) != ''),
    
    	(CreationDate: (trim payload01.CreationDate) as :date{format: "yyyy/MM/dd"})
    	when payload01.CreationDate? and ((trim payload01.CreationDate) != '')
    })]]></dw:set-payload>
            </dw:transform-message>
            <sfdc-analytics:upload-external-data-into-new-data-set-and-start-processing
    			config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
    			type="metadata.json:RELATIVE"
    			operation="UPSERT"
    			description="Test upload of 2500 records all in one step"
    			label="records_2500_in_one_step"
    			dataSetName="records_2500_in_one_step_with_app"
    			edgemartContainer="TestContainer"
    			notificationSent="ALWAYS"
    			notificationEmail="name@email.com"
    			doc:name="Salesforce Analytics Cloud">
                <sfdc-analytics:payload ref="#[payload]"/>
            </sfdc-analytics:upload-external-data-into-new-data-set-and-start-processing>
        </flow>
    </mule>

Example 2 Configure with the XML Editor

  1. Create a dataset and upload data into it by processing the data in several chunks.

  2. Add sfdc-analytics namespace to the Mule element as follows:

    xmlns:sfdc-analytics="http://www.mulesoft.org/schema/mule/sfdc-analytics"
  3. Add a location for the analytics schema referred to by the sfdc-analytics namespace with the following:

    http://www.mulesoft.org/schema/mule/sfdc-analytics
    http://www.mulesoft.org/schema/mule/sfdc-analytics/current/mule-sfdc-analytics.xsd
  4. Add the DataWeave namespace:

    xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
  5. Add the location of DataWeave schema referred by DataWeave namespace with the following value:

    http://www.mulesoft.org/schema/mule/ee/dw
    http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
  6. Add a context:property-placeholder element to your project, then configure its attributes as follows:

    <context:property-placeholder location="mule-app.properties"/>
  7. Add a sfdc-analytics:config element to your project, then configure its attributes as follows:

    <sfdc-analytics:config
    	name="Salesforce_Analytics_Cloud__Basic_authentication"
    	username="${salesforce.username}"
    	password="${salesforce.password}"
    	securityToken="${salesforce.securityToken}"
    	metadataFileName="${metadata.file.analytics}"
    	doc:name="Salesforce Analytics Cloud: Basic authentication"
    	url="${salesforce.url}"/>
  8. Add an empty batch:job element to your project as follows:

    <batch:job name="demoBatch">
        <batch:input>
        </batch:input>
        <batch:process-records>
        </batch:process-records>
        <batch:on-complete>
        </batch:on-complete>
    </batch:job>
  9. Add a file:inbound-endpoint element into batch:input of batch:job, then configure it as follows:

    <file:inbound-endpoint
    	path="path_to_folder_to_monitor"
    	moveToDirectory="path_to_folder_where_to_move_processed_files"
    	responseTimeout="10000"
    	doc:name="File For Batch">
    </file:inbound-endpoint>
  10. Add an empty enricher element into batch:input of batch:job, then configure it as follows:

    <enricher source="#[payload]"
    	target="#[variable:dataSetId]"
    	doc:name="Message Enricher">
    </enricher>
  11. Add a sfdc-analytics:create-data-set element into enricher, then configure it as follows:

    <sfdc-analytics:create-data-set
    	config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
    	operation="OVERWRITE"
    	description="${batch.dataSetDescription}"
    	label="${batch.dataSetLabel}"
    	dataSetName="${batch.dataSetName}"
    	edgemartContainer="${batch.dataSetEdgemartContainer}"
    	notificationSent="ALWAYS"
    	notificationEmail="name@email.com"
    	doc:name="Salesforce Analytics Cloud"/>
  12. Add a transform-message element into batch:input of batch:job, then configure it as follows:

    <dw:transform-message doc:name="Transform Message">
         <dw:set-payload><![CDATA[%dw 1.0
    %output application/java
    ---
    payload map ((payload01 , indexOfPayload01) -> {
    	(Id: (trim payload01.Id) as :number) when payload01.Id? and ((trim payload01.Id) != ''),
    	(Country: trim payload01.Country) when payload01.Country? and ((trim payload01.Country) != ''),
    	(City: trim payload01.City) when payload01.City? and ((trim payload01.City) != ''),
    	(Year: (trim payload01.Year) as :number) when payload01.Year? and ((trim payload01.Year) != ''),
    	(Distance: (trim payload01.Distance) as :number) when payload01.Distance? and ((trim payload01.Distance) != ''),
    	(Currencies: ((trim payload01.Currencies) splitBy ";") as :array)
    	when payload01.Currencies? and ((trim payload01.Currencies) != ''),
    	(CreationDate: (trim payload01.CreationDate) as :date{format: "yyyy/MM/dd"})
    	when payload01.CreationDate? and ((trim payload01.CreationDate) != '')
    })]]></dw:set-payload>
                </dw:transform-message>
  13. Add an empty batch:step element into batch:process-records of batch:job, then configure it as follows:

    <batch:step name="Batch_Step">
    </batch:step>
  14. Add an empty batch:commit element into batch:step of batch:process-records, then configure it as follows:

    <batch:commit  doc:name="Batch Commit" size="3000">
    </batch:commit>
  15. Add an sfdc-analytics:upload-external-data element into batch:commit of batch:step of batch:process-records, then configure it as follows:

    <sfdc-analytics:upload-external-data
    config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
    type="recordId"
    dataSetId="#[variable:dataSetId]"
    doc:name="Salesforce Analytics Cloud">
        <sfdc-analytics:payload ref="#[payload]"/>
    </sfdc-analytics:upload-external-data>
  16. Add an sfdc-analytics:start-data-processing element into batch:on-complete of batch:job, then configure it as follows:

    <sfdc-analytics:start-data-processing
    config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
    dataSetId="#[variable:dataSetId]"
    doc:name="Salesforce Analytics Cloud"/>
  17. In the end the XML file should look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <mule xmlns:batch="http://www.mulesoft.org/schema/mule/batch"
    xmlns:sfdc-analytics="http://www.mulesoft.org/schema/mule/sfdc-analytics"
    xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
    xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/batch
    http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
    http://www.mulesoft.org/schema/mule/file
    http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-current.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-current.xsd
    http://www.mulesoft.org/schema/mule/core
    http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/ee/dw
    http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
    http://www.mulesoft.org/schema/mule/sfdc-analytics
    http://www.mulesoft.org/schema/mule/sfdc-analytics/current/mule-sfdc-analytics.xsd">
    	<context:property-placeholder location="mule-app.properties"/>
    	<sfdc-analytics:config
    	name="Salesforce_Analytics_Cloud__Basic_authentication"
    	 username="${salesforce.username}"
    	 password="${salesforce.password}"
    	 securityToken="${salesforce.securityToken}"
    	 metadataFileName="${metadata.file.analytics}"
    	 doc:name="Salesforce Analytics Cloud: Basic authentication"
    	 url="${salesforce.url}"/>
    	<file:connector name="File" autoDelete="true" streaming="true"
    	validateConnections="true" doc:name="File"/>
    	<batch:job name="demoBatch">
            <batch:input>
                <file:inbound-endpoint path="path_to_folder_to_monitor"
                moveToDirectory="path_to_folder_where_to_move_processed_files"
                responseTimeout="10000"
                doc:name="File For Batch">
                </file:inbound-endpoint>
                <enricher source="#[payload]"
                 target="#[variable:dataSetId]" doc:name="Message Enricher">
                    <sfdc-analytics:create-data-set
                    config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
                    operation="OVERWRITE" description="desc" label="lbl"
                    dataSetName="dsTest" edgemartContainer="TestContainer"
                    notificationSent="ALWAYS" notificationEmail="name@email.com"
                    type="metadata.json:RELATIVE" doc:name="Salesforce Analytics Cloud"/>
                </enricher>
                <dw:transform-message doc:name="Transform Message">
                    <dw:set-payload><![CDATA[%dw 1.0
    %output application/java
    ---
    payload map ((payload01 , indexOfPayload01) -> {
    	(Id: (trim payload01.Id) as :number) when payload01.Id? and ((trim payload01.Id) != ''),
    	(Country: trim payload01.Country) when payload01.Country? and ((trim payload01.Country) != ''),
    	(City: trim payload01.City) when payload01.City? and ((trim payload01.City) != ''),
    	(Year: (trim payload01.Year) as :number) when payload01.Year? and ((trim payload01.Year) != ''),
    	(Distance: (trim payload01.Distance) as :number) when payload01.Distance? and ((trim payload01.Distance) != ''),
    	(Currencies: ((trim payload01.Currencies) splitBy ";") as :array)
    	when payload01.Currencies? and ((trim payload01.Currencies) != ''),
    	(CreationDate: (trim payload01.CreationDate) as :date{format: "yyyy/MM/dd"})
    	when payload01.CreationDate? and ((trim payload01.CreationDate) != '')
    })]]></dw:set-payload>
                </dw:transform-message>
            </batch:input>
            <batch:process-records>
                <batch:step name="Batch_Step">
                    <batch:commit  doc:name="Batch Commit" size="3000">
                        <sfdc-analytics:upload-external-data
                        config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
                        type="metadata.json:RELATIVE"
                        dataSetId="#[variable:dataSetId]"
                        doc:name="Salesforce Analytics Cloud">
                            <sfdc-analytics:payload ref="#[payload]"/>
                        </sfdc-analytics:upload-external-data>
                    </batch:commit>
                </batch:step>
            </batch:process-records>
            <batch:on-complete>
                <sfdc-analytics:start-data-processing
                config-ref="Salesforce_Analytics_Cloud__Basic_authentication"
                dataSetId="#[variable:dataSetId]" doc:name="Salesforce Analytics Cloud"/>
            </batch:on-complete>
        </batch:job>
    </mule>
View on GitHub