> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/salesforce.md).

# Salesforce

Salesforce is a CRM platform for tracking customer relationships, sales and service operations.

Frends offers seamless integration with [Salesforce](https://www.Salesforce.com), enabling you to effortlessly connect and automate data flows between your systems and Salesforce.

Frends has tasks for performing all core Salesforce operations.

By leveraging Frends' task-based approach, you can configure and customize Salesforce integrations according to your specific requirements. Frends offers a wide range of tasks that facilitate integrations to a variety of systems and protocols.

## Setting up the environment

To use the tasks in this package, you need a Salesforce environment. To create one, follow these steps:

1. Register to a Salesforce (for test purposes you can use a Developer Edition trial at [Salesforce](https://developer.salesforce.com/free-trials)).
2. Go to **Setup → Apps → External Client Apps → Settings**.
3. Enable **Allow creation of connected apps**.
4. Click **New Connected App**.
5. Fill in the following:
   * Required fields (*Connected App Name*, *API Name*, *Contact Email*).
   * Enable **OAuth Settings**.
   * Set the **Callback URL** (any valid URL, e.g., <https://www.google.com>).
   * Add **Full access (full)**, **Manage user data via APIs (api)** and **Perform requests at any time (refresh\_token, offline\_access)** to **Selected OAuth Scopes**.
   * Enable **Client Credentials Flow**.
6. Get the **Consumer Key** and **Consumer Secret** by clicking **Manage Consumer Details**.\
   You can retrieve them later by following these steps:
   * Go to **Setup → Apps → App Manager**.
   * Click **View** in the **Action** column next to your app.
   * Click **Manage Consumer Details** (you will need a verification code sent to the email address you provided during registration).
7. Go to **Setup → Identity → OAuth and OpenID Connect Settings**.
8. Enable **OAuth Username-Password Flows**.

*(Additional steps to set up PubSup API access)* 9. Enable events

* Go to Navbar → Platform Tools → Integrations → Change Data Capture
* Select Event (Event) and save changes

10. Get TenantId (OrgID)
    * Go to Navbar → Settings → Company Settings → Company Information
    * Tenant id is under Organization Detail -> Salesforce.com Organization ID
11. Create custom events
    * Go to Navbar → Platform Tools → Integrations → Platform Events
    * Click New Platform Event and set the following:
      * Label: Test Event
      * Plural Label: Test Events.
      * Object Name: Test\_Event (API Name will be "Test\_Event\_\_e").
      * Publish Behavior: Choose Publish After Commit.
    * Add Custom Fields:
    * Save, go to the event and Click New under Custom Fields (e.g., a Text field called Message).
12. Enable event permissions
    * Go to Navbar → Administration → Users → Permission Sets
    * Create new e.g. PubSub\_Test\_Access
    * Go to permission settings and click on Object settings
    * Select your test event and enable Read and Create permissions
    * Go back to permission settings and click Manage Assignments and add test user

***

**PubSub HINT**

To manually add an event, Click on GearIcon → DebugConsole Select Debug → Open Execute Anonymous Window In new windows type:

```
Test_Event__e event = new Test_Event__e(Message__c = 'Hello from UI a bit later!');
EventBus.publish(event);
```

And click Execute

***

To use the task, provide the following data:

* `Input.Domain` → The domain that was created for you after registration.
* `Options.AuthUrl` → By default: <https://login.salesforce.com/services/oauth2/token>
* `Options.ClientId` → Consumer Key from step 6.
* `Options.ClientSecret` → Consumer Secret from step 6.
* `Options.Username` → Your Salesforce username (check it in **Setup → Users → Users**).
* `Options.Password` → Password for your Salesforce user.
* `Options.SecurityToken` → Security token for your Salesforce user. You can get it as follows:
  * Click your profile icon → **Settings**.
  * Go to **My Personal Information → Reset My Security Token**.

    > **WARNING**: This will expire the previous Security Token, hence it may be a destructive operation!
  * The security token will be sent to the email address you provided during registration.

## Use cases

Below you will find typical use cases for Salesforce integrations and how they are implemented in Frends.

### Synchronize data to Salesforce

By using the [`CreateSObject`](/tasks/tasks/salesforce/createsobject.md) and [`UpdateSObject`](/tasks/tasks/salesforce/updatesobject.md) tasks we can create an integration that syncs customer data from another CRM system.

<figure><img src="https://2096450325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FevBo49UTUjEN84O2WPl6%2Fuploads%2Fgit-blob-f4f7309dfa5867737da5d266d4e1eb5ff4471afd%2Fsalesforce-sync.svg?alt=media" alt=""><figcaption><p>Sync</p></figcaption></figure>

### Query Salesforce data

By using the [`ExecuteQuery`](/tasks/tasks/salesforce/executequery.md) task we can create an integration that queries Salesforce for customer data.

<figure><img src="https://2096450325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FevBo49UTUjEN84O2WPl6%2Fuploads%2Fgit-blob-c91a3e3b292e9fd55c0e111e795d22c100de1847%2Fsalesforce-get-customer-data.svg?alt=media" alt=""><figcaption><p>Get customer</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/salesforce.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
