

# Reading from Salesforce Marketing Cloud entities
<a name="salesforce-marketing-cloud-reading-from-entities"></a>

**Prerequisite**

A Salesforce Marketing Cloud object you would like to read from. You will need the object name such as `Activity` or `Campaigns`. The following table shows the supported entities.

**Supported entities for source**:


| Entity | Interface | Can be filtered | Supports limit | Supports Order by | Supports SELECT \$1 | Supports partitioning | 
| --- | --- | --- | --- | --- | --- | --- | 
| Event Notification Callback | REST | No | No | No | Yes | No | 
| Seed-List | REST | No | Yes | No | Yes | No | 
| Setup | REST | Yes | Yes | No | Yes | No | 
| Domain Verification | REST | Yes | Yes | Yes | Yes | No | 
| Objects Nested Tags | REST | Yes | No | No | Yes | No | 
| Contact | REST | No | Yes | No | Yes | No | 
| Event Notification Subscription | REST | No | No | No | Yes | No | 
| Messaging | REST | No | Yes | No | Yes | No | 
| Activity | SOAP | No | No | No | Yes | Yes | 
| Bounce Event | SOAP | No | No | No | Yes | Yes | 
| Click Event | SOAP | No | No | No | Yes | Yes | 
| Content Area | SOAP | No | No | No | Yes | Yes | 
| Data Extension | SOAP | No | Yes | No | Yes | Yes | 
| Email | SOAP | No | Yes | No | Yes | Yes | 
| Forwarded Email Event | SOAP | No | Yes | No | Yes | Yes | 
| Forward Email OptInEvent | SOAP | No | Yes | No | Yes | Yes | 
| Link | SOAP | No | Yes | No | Yes | Yes | 
| Link Send | SOAP | No | Yes | No | Yes | Yes | 
| List | SOAP | No | Yes | No | Yes | Yes | 
| List Subscriber | SOAP | No | Yes | No | Yes | Yes | 
| Not Sent Event | SOAP | No | Yes | No | Yes | Yes | 
| Open Event | SOAP | No | Yes | No | Yes | Yes | 
| Send | SOAP | No | Yes | No | Yes | Yes | 
| Sent Event | SOAP | No | Yes | No | Yes | Yes | 
| Subscriber | SOAP | No | Yes | No | Yes | Yes | 
| Survey Event | SOAP | No | Yes | No | Yes | Yes | 
| Unsub Event | SOAP | No | Yes | No | Yes | Yes | 
| Audit Events | REST | No | Yes | Yes | Yes | No | 
| Campaigns | REST | No | Yes | Yes | Yes | No | 
| Interactions | REST | No | Yes | Yes | Yes | No | 
| Content Assets | REST | No | Yes | Yes | Yes | No | 

**Example for REST**:

```
salesforcemarketingcloud_read = glueContext.create_dynamic_frame.from_options(
    connection_type="salesforcemarketingcloud",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "Campaigns",
        "API_VERSION": "v1",
        "INSTANCE_URL": "https://**********************.rest.marketingcloudapis.com"
    }
)
```

**Example for SOAP**:

```
salesforcemarketingcloud_read = glueContext.create_dynamic_frame.from_options(
    connection_type="salesforcemarketingcloud",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "Activity",
        "API_VERSION": "v1",
        "INSTANCE_URL": "https://**********************.soap.marketingcloudapis.com"
    }
)
```

**Salesforce Marketing Cloud entity and field details**:

The following tables describe the Salesforce Marketing Cloud entities. There are REST entities with static metadata and SOAP entities with dynamic metadata.

**REST entities with static metadata**:

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/glue/latest/dg/salesforce-marketing-cloud-reading-from-entities.html)

**SOAP entities with dynamic metadata**:

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/glue/latest/dg/salesforce-marketing-cloud-reading-from-entities.html)

## Partitioning queries
<a name="salesforce-marketing-cloud-reading-partitioning-queries"></a>

In Salesforce Marketing Cloud, the Integer and DateTime datatype fields support field-based partitioning.

You can provide the additional Spark options `PARTITION_FIELD`, `LOWER_BOUND`, `UPPER_BOUND`, and `NUM_PARTITIONS` if you want to utilize concurrency in Spark. With these parameters, the original query would be split into `NUM_PARTITIONS` number of sub-queries that can be executed by Spark tasks concurrently.
+ `PARTITION_FIELD`: the name of the field to be used to partition the query.
+ `LOWER_BOUND`: an **inclusive** lower bound value of the chosen partition field.

  For the timestamp field, we accept the Spark timestamp format used in Spark SQL queries.

  Examples of valid value:

  ```
  “2024-05-07T02:03:00.00Z"
  ```
+ `UPPER_BOUND`: an **exclusive** upper bound value of the chosen partition field.
+ `NUM_PARTITIONS`: the number of partitions.

Example:

```
salesforcemarketingcloud_read = glueContext.create_dynamic_frame.from_options(
    connection_type="salesforcemarketingcloud",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "ListSubscriber",
        "API_VERSION": "v1",
        "PARTITION_FIELD": "CreatedDate",
        "LOWER_BOUND": "2023-09-07T02:03:00.000Z",
        "UPPER_BOUND": "2024-05-07T02:03:00.000Z",
        "NUM_PARTITIONS": "10"
    }
)
```