Contact Free trial Login

Salesforce Analytics Cloud Connector - Mule 4

Support Category: Select

Salesforce Analytics Connector v3.1

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

Prerequisites

To use this information, you should be familiar with Salesforce Analytics, Mule, Anypoint Connectors, Anypoint Studio, Mule concepts, elements in a Mule flow, and Global Elements.

You need login credentials to test your connection to your target resource.

For software requirements and compatibility information, see the Connector Release Notes.

POM File Information

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-sfdc-analytics-connector</artifactId>
  <version>RELEASE</version>
  <classifier>mule-plugin</classifier>
</dependency>

Mule converts RELEASE to the latest version. To specify a version, view Salesforce Einstein Analytics Connector in Anypoint Exchange and click Dependency Snippets.

Connect in Design Center

  1. In Design Center, click a trigger such as this connector as they trigger, HTTP Listener,or Scheduler trigger.

  2. To create an optional global element for the connector, you can choose from the following options. More information is provided in the sections that follow, and links to Salesforce documents are listed in the See Also section of this document.

    • Required Parameters for Basic Username Password Authentication

    • Required Parameters for the OAuth 2.0 Configuration

    • Required Parameters for the OAuth 2.0 JWT Bearer Configuration

    • Required Parameters for the OAuth 2.0 SAML Bearer Configuration

      Choose Global Type
  3. Select the plus sign to add a component.

  4. Select the connector as a component.

  5. Configure these fields for Upload external data into new dataSet and start processing operation:

    • Type - Type of the records to be inserted. You need to upload a JSON file representing the schema of the dataset to be created.

    • Records - Data sense expression; the records to be inserted

    • Operation - Which operation to use when you’re loading data into the DataSet

    • Description

    • Label

    • Data Set Name

      Upload and start processing

Required Parameters for Basic Username Password Authentication

  • Username: Enter the Salesforce Analytics username.

  • Password: Enter the corresponding password.

  • Security Token: Enter the corresponding security token.

Basic Authentication

Required Parameters for the OAuth 2.0 Configuration

  • Consumer Key - The consumer key for the Salesforce connected app.

  • Consumer Secret - The consumer secret for the connector to access Salesforce.

OAuth Authentication

Required Parameters for the OAuth 2.0 JWT Bearer Configuration

  • Consumer Key - The consumer key for the Salesforce connected app.

  • Keystore File - See Generating a Keystore File.

  • Store Password - The password for the keystore.

  • Principal - The Salesforce username that you want to use.

JWT Bearer Configuration

Required Parameters for the OAuth 2.0 SAML Bearer Configuration

  • Consumer Key - The consumer key for the Salesforce connected app.

  • Keystore File - The path to the key store used to sign data during authentication* Only Java key store format is allowed.

  • Store Password - Key store password

  • Principal - Username of desired Salesforce user

SAML Bearer Configuration

Generating a Keystore File

The Keystore is the path to the keystore used to sign data during authentication. Only Java keystore format is allowed.

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

  3. Enter the following details:

    • Password for the keystore.

    • Your first name and last name.

    • Your organization unit.

    • Name of your city, state, and the two letter code of your county.

      The system generates a java keystore file containing a private/public key pair in your workspace.

  4. Provide the file path for the Keystore in your connector configuration.

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

    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.

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

Add the Connector to a Studio Project

Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.

Add the Connector Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange icon (X) in the upper-left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for "analytics".

  5. Select the connector and click Add to project.

  6. Follow the prompts to install the connector.

Add the Connector in Studio

  1. In Studio, create a Mule project.

  2. In the Mule Palette view, click (X) Search in Exchange.

  3. In Add Modules to Project, type "analytics" in the search field.

  4. Click this connector’s name in Available modules.

  5. Click Add.

  6. Click Finish.

Configure in Studio

  1. Drag the connector to the Studio canvas.

  2. To create a global element for the connector, set these fields:

    • Basic Authentication:

      • Username: Enter the Salesforce username.

      • Password: Enter the corresponding password.

      • Security Token: Enter the corresponding security token.

        Basic Authentication
    • OAuth 2.0:

      • Consumer Key - The consumer key for the Salesforce connected app.

      • Consumer Secret - The consumer secret for the connector to access Salesforce.

        OAuth Authentication
    • OAuth 2.0 JWT:

      • Consumer Key - The consumer key for the Salesforce connected app.

      • Keystore File - See Generating a Keystore File.

      • Store Password - The password for the keystore.

      • Principal - The password for the keystore.

        OAuth 2.0 JWT Authentication
    • OAuth 2.0 SAML:

      • Consumer Key - The consumer key for the Salesforce connected app.

      • Keystore File - See Generating a Keystore File.

      • Store Password - The password for the keystore.

      • Principal - The password for the keystore.

        OAuth 2.0 SAML Authentication
  3. Configure these fields for upload external data into new dataSet and start processing operation:

    • Type - Type of the records to insert. Select a JSON file representing the schema of the dataset to be created.

    • Records - DataSense expression - the records to be inserted.

    • Operation - Which operation to use when you’re loading data into a data set.

    • Description

    • Label

    • Data Set Name

      Upload external data

Use Case: Studio

This use case provides an example of how to use the Salesforce Analytics Connector and contains this end to end flow:

  • A trigger represented by the HTTP listener.

  • A Salesforce Analytics configuration containing a username, password, and the security token.

  • A Salesforce Analytics operation with the parameters to use.

The example that follows contains these components:

  • HTTP Listener - Accepts data from http requests.

  • Transform Message - Provides the records input data required by Salesforce analytics connector.

%dw 2.0
---
output application/java
[
	{
		"Id": 1,
		"Country": "Country",
		"City": "City",
		"Year": 428742153,
		"Distance": 284644936,
		"Currencies":
		[
			"EUR",
			"USD"
		],
		"CreationDate": "20/12/2017" as Date {format: "dd/MM/yyyy"}
	},
	{
		"Id": 2,
		"Country": "Country",
		"City": "City",
		"Year": 1432651434,
		"Distance": 1336594394,
		"Currencies":
		[
			"EUR",
			"USD",
			"HUF"
		],
		"CreationDate": "20/12/2017" as Date {format: "dd/MM/yyyy"}
	}
]
  • Salesforce Analytics connector - Connects with Salesforce, and performs an operation to push data into Salesforce Analytics.

Use case

Use Case: XML

Paste this XML code into Anypoint Studio to experiment with the flow described in the previous section. Keep in mind that you still have to provide the metadata.json file describing the schema of the dataset to be created.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:salesforce-analytics="http://www.mulesoft.org/schema/mule/salesforce-analytics"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file
http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/salesforce-analytics
http://www.mulesoft.org/schema/mule/salesforce-analytics/current/mule-salesforce-analytics.xsd">
 	<configuration-properties file="mule-app.properties" />
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<salesforce-analytics:salesforce-analytics-config
	  name="Salesforce_Analytics_Salesforce_Analytics"
	  doc:name="Salesforce Analytics Salesforce Analytics" >
		<salesforce-analytics:basic-connection username="${salesforce.username}"
		   password="${salesforce.password}" securityToken="${salesforce.securityToken}"
		   url="${salesforce.url}"/>
	</salesforce-analytics:salesforce-analytics-config>
	<flow name="upload-all-in-one-with-append" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="append"/>
		<ee:transform doc:name="Transform Message" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
[
	{
		"Id": 1,
		"Country": "Country",
		"City": "City",
		"Year": 428742153,
		"Distance": 284644936,
		"Currencies":
		[
			"EUR",
			"USD"
		],
		"CreationDate": "20/12/2017" as Date {format: "dd/MM/yyyy"}
	},
	{
		"Id": 2,
		"Country": "Country",
		"City": "City",
		"Year": 1432651434,
		"Distance": 1336594394,
		"Currencies":
		[
			"EUR",
			"USD",
			"HUF"
		],
		"CreationDate": "20/12/2017" as Date {format: "dd/MM/yyyy"}
	}
]]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<salesforce-analytics:upload-external-data-into-new-data-set-and-start-processing
		  doc:name="Upload external data into new data set and start processing"
		  config-ref="Salesforce_Analytics_Salesforce_Analytics" operation="APPEND"
		  description="${allInOne.dataSetDescription}" label="${allInOne.dataSetLabel}"
		  dataSetName="${allInOne.dataSetName}" edgemartContainer="${allInOne.dataSetContainerName}"
		  type="metadata.json" notificationSent="ALWAYS" notificationEmail="${notification.email}"/>
	</flow>
</mule>

See Also