BLOCKS Reference

Salesforce

Upload to Analytics from a variable

Overview

This BLOCK uploads data stored in a variable to an Einstein Analytics dataset. Metadata for the data to be uploaded should also be included.

Upload to Analytics from a variable BLOCK overview

Prepare your data as an array of objects. See the Data format section for details.

The Execute query BLOCK (BigQuery category) returns query results in a variable with this data format. As such, you don’t need to worry about the data’s formatting if simply upload query results from an Execute query BLOCK.

Overview of connecting an Execute query BLOCK with the Upload to Analytics from a variable BLOCK

You should also include JSON format metadata for the structure of the data to be uploaded.

For example, take the following image and JSON metadata. To upload the data in the image, you would create metadata like that shown below notating the formatting, data format, etc., for name, amount, and close_date. Refer to Analytics External Data Format Reference for more details on creating metadata.

Upload to Analytics from a variable example data
{
  "fileFormat": {
    "charsetName": "UTF-8",
    "fieldsEnclosedBy": "\"",
    "fieldsDelimitedBy": ",",
    "numberOfLinesToIgnore": 1
  },
  "objects": [
    {
      "connector": "AcmeCSVConnector",
      "description": "",
      "fullyQualifiedName": "SalesData",
      "label": "Sales Data",
      "name": "SalesData",
      "fields": [
        {
          "description": "",
          "fullyQualifiedName": "SalesData.Name",
          "label": "Account Name",
          "name": "name",
          "isSystemField": false,
          "isUniqueId": false,
          "isMultiValue": false,
          "type": "Text"
        },
        {
          "description": "",
          "fullyQualifiedName": "SalesData.Amount",
          "label": "Opportunity Amount",
          "name": "amount",
          "isSystemField": false,
          "defaultValue": "0",
          "isUniqueId": false,
          "type": "Numeric",
          "precision": 10,
          "scale": 2,
          "format": "$#,##0.00"
        },
        {
          "description": "",
          "fullyQualifiedName": "SalesData.CloseDate",
          "label": "Opportunity Close Date",
          "name": "close_date",
          "isSystemField": false,
          "isUniqueId": false,
          "type": "Date",
          "format": "yyyy-MM-dd",
          "fiscalMonthOffset": 0
        }
      ]
    }
  ]
}

Although it is possible to leave the Metadata JSON property blank, we recommend setting it. When left blank, all data is handled as text only.

Data format

As mentioned previously, you should prepare the data to be uploaded as an array of objects.

You do not need to worry about this formatting when directly uploading query results from the Execute query BLOCK. Refer to this section when preparing data from another source.

We will use the following image of sales data to explain how to prepare your data for uploading.

Upload to Analytics from a variable sample data

Create an object for each record (row), then combine them into an array.

Upload to Analytics from a variable example array

An object contains data as multiple key and value pairs.

Upload to Analytics from a variable example object

You can create an array of objects using the Construct object BLOCK from the Basic category. Set objects by selecting the Object type and arrays by selecting the Array type.

Upload to Analytics from a variable: Construct object BLOCK example

If you want to pass data to the Flow from an external application, prepare your data in JSON format.

[
  {
    "name": "opportunityA",
    "amount": 100.99,
    "sales_date": "2014-06-30"
  },
  {
    "name": "opportunityB",
    "amount": 99.01,
    "sales_date": "2012-01-31"
  }
]

Properties

Property Explanation
BLOCK name Configure the name displayed on this BLOCK.
Account

Select a Salesforce account.

You must register a Salesforce account into the Salesforce accounts section of the settings menu beforehand.

Source data variable Designate the variable containing the data to be uploaded to an Einstein Analytics Dataset.
Dataset Designate the Einstein Analytics Dataset to which data will be uploaded.
Metadata JSON

Designate JSON format metadata for the structure of the data to be uploaded.

See Analytics External Data Format Reference for details on creating metadata.

Sandbox Designate whether or not the upload destination is a Salesforce Sandbox environment.
BLOCK memos Make notes about this BLOCK.
Operation

Select the operation to use when loading data into the dataset.

  • Overwrite: Creates a dataset with the uploaded data. If the dataset already exists, it will overwrite it.
  • Append: Adds the uploaded data to a dataset. Creates a new dataset if it does not already exist. This cannot be used if the dataset or data contains a unique identifier.
  • Upsert: Inserts new rows or updates existing rows in the dataset. Creates a new dataset if it does not already exist. When using this operation, the data must include one field containing a unique identifier.
  • Delete: Delete rows from the dataset. When using this operation, the rows to delete must include one field containing a unique identifier.

Metadata is required to use the append, upsert, and delete operations.

  • Append and upsert: The data to be uploaded, metadata, and the destination dataset must match exactly.
  • Delete: The metadata must be a subset of the destination dataset’s columns.

この情報は役に立ちましたか?