> ## Documentation Index
> Fetch the complete documentation index at: https://help.treble.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CRM Action Block

> How to write data to Salesforce from a conversation: create and update records, choose which one gets updated and save what the person answers.

The **CRM Action** block writes to Salesforce from the conversation flow. With it you can save what the person answers, mark the source of a lead, change the status of a request or create a new record.

The block has a different name depending on your integration type:

| Integration type | Block name |
| - | - |
| Single object | **CRM Action** |
| Multi-object | **CRM Multiple Object Action** |

<Note>
  In multi-object the names are very similar and easy to mix up. The one that **writes** is *CRM Multiple Object **Action***. The one that only **reads** is called *CRM Multiple Object*, without "Action".
</Note>

<div class="hr" />

## What to understand first

Each CRM Action block writes **a single property**. If you need to save three pieces of data, you will use three blocks.

In addition, the block does two different things depending on the case:

* If it **finds** the person's record, it **updates** it.
* If it **does not find it**, it **creates** it.

<Warning>
  This difference matters more than it seems. Some Salesforce fields only accept values at creation time: for example, a field that a validation rule requires on create, or the record type of a Person Account.

  Since the block writes **after** the record is created, in those cases the value arrives too late. If you run into this, check [advanced settings](/en/docs/integrations/salesforce/features/advanced-settings).
</Warning>

<div class="hr" />

## Add the block

From the conversation builder, open the blocks panel and look for **CRM Action** under *Advanced blocks*.

<img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-so-1.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=713e44e904074b7124448ec14bdc859a" alt="Adding the CRM Action block to the flow" className="mx-auto" width="3024" height="1710" data-path="images/salesforce-crm-action-so-1.png" />

Drag it onto the canvas and click **Settings** to open it.

<div class="hr" />

## Configuration

<Tabs>
  <Tab title="Single object">
    ### 1. Object and hierarchy

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-so-2.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=d8f8eb7c08e6bbc1264c33a89de60e1e" alt="Selecting the Salesforce object" className="mx-auto" width="3024" height="1712" data-path="images/salesforce-crm-action-so-2.png" />

    **Object.** Choose which object you are going to write to. It can be your parent entity (for example `Contact`) or one of its related objects.

    **Hierarchy.** Defines what happens when the person has **more than one record** of that object. It is an important decision and easy to overlook.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-so-3.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=d8ba7290dd6ecce2b95659757d1fb7c2" alt="Hierarchy options" width="500" className="mx-auto" data-path="images/salesforce-crm-action-so-3.png" />

    | Option | What it does |
    | - | - |
    | **First created** | Uses the oldest record |
    | **Last created** | Uses the most recent record. It is the most common option |
    | **Custom** | You define a filter: for example, the record whose *Status* field is *Active* |

    ### 2. Property and value

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-so-4.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=c56f512df8380388a2f48cef0067f01a" alt="Choosing the property and the value to save" className="mx-auto" width="3024" height="1714" data-path="images/salesforce-crm-action-so-4.png" />

    **Property.** The Salesforce field you are going to write.

    **Value.** What you want to save. It can be fixed text, or a conversation variable using double curly braces, for example `{{nombre}}`.

    <Info>
      The field type changes how this part looks. If it is a picklist, you will see the available options instead of a text box. If the options you expect do not appear, you probably need to [sync objects](/en/docs/integrations/salesforce/object-sync).
    </Info>

    ### 3. Create a new object

    At the bottom of the modal there is a toggle: **"Create a new object with this configuration"**.

    <Warning>
      If you turn it on, Treble **always creates a new record**, without first checking whether the person already exists.

      Use it only when you really want one record per conversation (for example, a new request each time). If you turn it on for the main object by mistake, you will end up with a duplicate contact for every conversation.
    </Warning>
  </Tab>

  <Tab title="Multi-object">
    In multi-object the block asks for one more step at the beginning, because you first have to say **which of your objects** you are working on. The modal has three numbered steps.

    ### 1. Reference object and phone field

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-mo-1.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=564894f1a94626749ba6b4f1b4e2a012" alt="Steps 1 and 2 of the CRM Multiple Object Action block" className="mx-auto" width="3020" height="1710" data-path="images/salesforce-crm-action-mo-1.png" />

    **Reference object.** Which of the objects you configured during installation you are going to use in this block (for example `Lead`, `Account` or a custom object).

    **Phone lookup field.** Which field of that object is used to look up the person.

    <Warning>
      This field serves **two purposes at once**: it is where Treble looks up the record, and also where it writes the number when it creates one.

      Changing it later affects both. If all your historical records have the number in the previous field, Treble will stop finding them and will start creating duplicates. Check [advanced settings](/en/docs/integrations/salesforce/features/advanced-settings) before changing it.
    </Warning>

    ### 2. Object and hierarchy

    On the same screen, step 2 asks for the object you are going to write to and the hierarchy. It can be the same reference object or a related one.

    In addition to *First created* and *Last created*, multi-object offers **Custom**, which lets you point to a specific record with a property and a value:

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-mo-2.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=a0d872f99c21622947314b86743ae2a4" alt="Custom hierarchy with property and value" className="mx-auto" width="3024" height="1706" data-path="images/salesforce-crm-action-mo-2.png" />

    <Tip>
      The value accepts conversation variables. In the example, `Account ID = {{client_id}}` writes exactly to the account whose Id was saved in the `{{client_id}}` variable — useful when you already read the Id in a previous block and want to make sure you write to that record and not another one.
    </Tip>

    ### 3. Property and value

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-mo-3.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=f820f28572624e2aa793b5f146286477" alt="Property to write and value to save" className="mx-auto" width="3024" height="1706" data-path="images/salesforce-crm-action-mo-3.png" />

    **Property.** The Salesforce field you are going to write (in the example, `Account Name`).

    **Save as text.** The value. It can be fixed text or a variable with double curly braces, for example `{{nombre_cuenta}}`.

    <Warning>
      Below it is the **"Create a new object with this configuration"** toggle. If you turn it on, Treble **always creates a new record** of the object from step 2, without first checking whether it already exists.

      Use it only when you really want one record per conversation. If you turn it on for your main object by mistake, you will end up with a duplicate record for every conversation.
    </Warning>
  </Tab>
</Tabs>

<div class="hr" />

## How it looks in the flow

Once configured, the block shows a summary of what it does, so you can read the flow without opening each one.

In **single object** it looks like this:

```
Object: Contact
Hierarchy: Last created
In the property: Lead Source
  ↳ Set: Web
```

In **multi-object** the summary also includes the reference object and the lookup field:

<img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-crm-action-mo-4.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=c6e0b278f032d99496fee0d8bfbf725c" alt="Read and write blocks on the flow canvas" className="mx-auto" width="3018" height="1712" data-path="images/salesforce-crm-action-mo-4.png" />

On the left is the **read** block (*CRM Multiple Object*, which ends in a variable) and on the right the **write** block (*CRM Multiple Object Action*, which ends in *In the property → Set*). The icon and the last box of the summary are the quickest way to tell them apart at a glance.

<div class="hr" />

## When it writes, and why the order matters

Each block writes to Salesforce **at the exact moment the conversation passes through it**. It does not wait for the end of the flow, and it is not undone if the person abandons the conversation afterwards.

<Warning>
  **Incomplete conversations also leave data behind.** If you place an action block right after the first question and the person drops off there, that data has already been written to Salesforce.

  This is the cause of the most common complaint about "junk information in the CRM".
</Warning>

### How to avoid partial data

<AccordionGroup>
  <Accordion title="Write at the end, not along the way">
    Save the answers in conversation variables during the flow, and place **all** the action blocks together at the end, after the last question.

    That way only the information of those who completed the flow reaches the CRM.

    <a class="article-link" href="/en/docs/integrations/salesforce/blocks/crm-variable-assignment"><p>How to save to variables</p><Icon icon="arrow-up-right-from-square" iconType="solid" /></a>
  </Accordion>

  <Accordion title="Mark who completed the flow">
    If you prefer to write along the way —for example so you don't lose the data of those who drop off— add one last action block that marks a "flow completed" type of field. You can then filter by that field in Salesforce.
  </Accordion>

  <Accordion title="Do I need to connect another block after the action block?">
    Not for the write to happen: the block writes when the flow passes through it, whether or not there is a next block.

    But yes for the flow to make sense: an action block does not say anything to the person. If it is the last step, the usual thing is to add a closing message after it.
  </Accordion>
</AccordionGroup>

<div class="hr" />

## Common issues

<AccordionGroup>
  <Accordion title="The field I want does not appear in the list">
    It is almost always a lack of sync. Run the [object sync](/en/docs/integrations/salesforce/object-sync) and open the block again.
  </Accordion>

  <Accordion title="Salesforce rejects a picklist value that does exist">
    It is usually the **record type**. Record types define which picklist values are valid on each record, so a value that is correct for one type can be invalid for another.

    <a class="article-link" href="/en/docs/integrations/salesforce/features/record-types"><p>Record types</p><Icon icon="arrow-up-right-from-square" iconType="solid" /></a>
  </Accordion>

  <Accordion title="The data is saved to a different record than I expected">
    Check the **hierarchy**. If the person has several records and you chose *Last created*, the block writes to the most recent one, which may not be the one you have open in Salesforce.
  </Accordion>

  <Accordion title="The CRM name field ends up with the text of a message">
    For example, a contact whose name in Salesforce ended up as *"Hi, I saw the ad and I want information"*.

    It is almost always an action block writing the **person's answer** to the name field. Check which property that block has configured: it is easy to point to `Name` or `FirstName` when you actually wanted a custom field.
  </Accordion>

  <Accordion title="Duplicate records are being created">
    Check whether the **"Create a new object"** toggle is turned on in a block where it shouldn't be. Also check that the phone lookup field is the same one where the numbers of the existing records are stored.
  </Accordion>

  <Accordion title="Salesforce responds that it was saved, but the field stays empty">
    There may be an automation in your Salesforce (a Flow, Process Builder or trigger) that clears or overwrites that field after the record is created.

    A quick way to confirm it: if the value **is** saved when writing to a record that already exists, but **not** when it is created, there is almost certainly an automation that runs on creation.
  </Accordion>
</AccordionGroup>

<div class="hr" />

## Next steps

<CardGroup cols={2}>
  <Card title="Read data from Salesforce" icon="download" href="/en/docs/integrations/salesforce/blocks/crm-variable-assignment">
    Bring a value from Salesforce into a conversation variable.
  </Card>

  <Card title="Advanced settings" icon="sliders" href="/en/docs/integrations/salesforce/features/advanced-settings">
    What to do when a field must be written at creation time.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.