---
schema_version: "1"
id: 7dbddf7323e7caf122545969264f7047b3754abc136cd23300c690c1f3a7db8b
title: String Functions for Formulas
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/data/264-0-0/c360_a_batch_transform_string.md
canonical_url: https://help.salesforce.com/s/articleView?id=data.c360_a_batch_transform_string.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 77ae5f551c15b9bad9931085f97286f290f6d88eb2d2a28ae45f95818eb1a06b
description: Use a string function to manipulate the text data type, including email, phone, time, and date values. For example, change text from uppercase to lowercase, concatenate values from multiple fields, and replace values.
products:
  - Data 360
release: "264"
---
# String Functions for Formulas

Use a string function to manipulate the text data type, including email, phone, time, and date values. For example, change text from uppercase to lowercase, concatenate values from multiple fields, and replace values.

When you enter a formula, use the API name of the field in the expression, not the label. Enclose text in single straight quotes (`'This is a string.'`) and parameters in parentheses.

Formula expressions support these string functions.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
      <colgroup>
        <col style="width:11.614401858304298%">
        <col style="width:17.18931475029036%">
        <col style="width:71.19628339140534%">
      </colgroup>
      <thead class="slds-text-title_caps ">
        <tr class="">
          <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d112321e47">String Function</th>
          <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d112321e50">Description</th>
          <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d112321e53">Syntax</th>
        </tr>
      </thead>
      <tbody>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>char_length</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns the number of characters in the specified string. Length includes leading and
            trailing spaces.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>char_length(<var>field</var>)</code>
            </p>
            <p><var>field</var> is the text
              field to
              measure.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>char_length(product_name)</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>concat</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns a string by merging the values of the specified fields and input
            strings.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>concat(<var>field1</var>,<var>field2</var>,...<var>fieldN</var>)</code>
            </p>
            <p><var>field1</var>
              is the first text field to include in the concatenated
              value.</p>
            <p><var>field2</var> is the second text field to
              include.</p>
            <p><var>fieldN</var> is any number of additional text fields to
              include.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>concat("OwnerId.FirstName",' ',"OwnerId.LastName")</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>endsWith</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns True if the specified string is found at the end of the field value. You can
            use this function only in <code>case</code> functions. </td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p><code>ends_with(<var>fieldName</var>,<var>literal</var></code>)</p>
            <p><var>fieldName</var>
              is the text field to search.</p>
            <p style="margin-bottom:0;"><var>literal</var> is the value to search for at
              the end of the field.</p>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>instr</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns the first location of the text in the specified field. You can specify a
            different position to start the search or find the location of a different search
            string.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>instr(<var>field</var>,
         <var>searchString</var>, [<var>position</var>,
         [<var>occurrence</var>]])</code>
            </p>
            <p><var>field</var> is the text field
              evaluated to find the <var>searchString</var>.</p>
            <p><var>searchString</var>
              is the text field searched for in the
              <var>field</var>.
            </p>
            <p><var>position</var> is the location in
              <var>field</var> where to start the search. If you don't specify a position, the
              search begins at position 1.
            </p>
            <p><var>occurrence</var> is the
              <var>searchString</var> instance to return. If you don’t specify a position with
              the occurrence, the search begins at position 1.
            </p>
            <p>Example: Evaluate text for an
              exclamation point</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>instr('123!456!78!', !)
--The result is 4


instr('123!456!8!', !, [4])
--The result is 7


instr('123!456!8!', !, [4, [2]])
--The result is 9</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>lower</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns the string with all characters in lowercase. If the input string is null, the
            result is null.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>lower(<var>field</var>)</code>
            </p>
            <p><var>field</var> is the text field to
              convert to
              lowercase.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>lower("Account.Industry")</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>ltrim</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Removes the specified characters from the beginning of a string in a field. If you
            don’t specify characters, it removes the string’s leading spaces.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p><code>ltrim(<var>field</var>,[<var>valueToBeRemoved</var>]</code>)</p>
            <p><var>field</var>
              is the text field to remove the leading spaces or specified characters
              from.</p>
            <p><var>valueToBeRemoved</var> is the value to remove from the string. If
              unspecified, the transformation removes the leading spaces.</p>
            <p>Example: Trim the leading
              space characters from a
              string</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>ltrim('     5 Spaces Before')</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 "><code>md5</code></td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns a 32-character string that is a text representation of the hexadecimal
            value of a 128-bit checksum.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p><code>md5(<var>field</var>)</code></p>
            <p><var>field</var>
              (Required) is the text for which you want to calculate the
              checksum.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x" id="c360_a_batch_transform_string__codeblock_njs_1zf_w2c"><a name="c360_a_batch_transform_string__codeblock_njs_1zf_w2c"><!-- --></a><code>md5("Account_Name")</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>replace</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Replaces a string with another string. If any argument is null, the function returns
            null. This function is case-sensitive.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>replace(<var>field</var>,<var>searchString</var>,<var>replacementString</var>)</code>
            </p>
            <p><var>string</var> is the text field that contains the string to
              replace.</p>
            <p><var>searchString</var> is the string to replace. </p>
            <p><var>replacementString</var> is the value to replace the string.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>replace(Account_Name,'salesforce.com','Salesforce') </code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>rtrim</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Removes the specified characters from the end of a string in a field. If you don’t
            specify characters, it removes the string’s trailing spaces.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p><code>rtrim(<var>field</var>,
         [<var>valueToBeRemoved</var>]</code>)</p>
            <p><var>field</var> is the text
              field to remove the trailing spaces or specified substring
              from.</p>
            <p><var>valueToBeRemoved</var> is the value to remove from the string. If
              unspecified, the transformation removes the trailing spaces.</p>
            <p>Example: Trim the two
              trailing space characters from a
              string</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>rtrim('2 Spaces After  ')</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 "><code>sha2</code></td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Converts a variable-length string of characters into a fixed-length string of
            characters. The character string is a text representation of the hexadecimal value of
            the checksum with the specified number of bits. SHA-224, SHA-256, SHA-384, and SHA-512
            are supported. Bit length of 0 is equivalent to 256.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p><code>sha2(<var>field</var>, <var>bitLength</var></code></p>
            <p dir="ltr"><var>field</var> (Required) is the text to convert into a into a
              character string.</p>
            <p><var>bitLength</var> (Required) is an integer that
              defines the number of bits in the hash function. Valid values are 0, 224, 256, 384,
              and 512.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x" id="c360_a_batch_transform_string__codeblock_vqg_c1g_w2c"><a name="c360_a_batch_transform_string__codeblock_vqg_c1g_w2c"><!-- --></a><code>sha2('account_name', 224);</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>startsWith</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns True if the specified string is found at the beginning of the field value. You
            can use this function only in <code>case</code> functions. </td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p><code>startsWith(<var>fieldName</var>,<var>literal</var></code>)</p>
            <p><var>fieldName</var>
              is the text field to search.</p>
            <p style="margin-bottom:0;"><var>literal</var> is the value to search for at
              the beginning of the field.</p>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>string</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Converts the date or number value to a string data type.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>string(<var>expression</var>)</code>
            </p>
            <p style="margin-bottom:0;"><var>expression</var> is the date
              or number field to convert.</p>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>substr</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns the specified number of characters from the string, starting at the specified
            position. Also called <code>substring</code>.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>substr(<var>field</var>,<var>position</var>,<var>len</var>)</code>
            </p>
            <p><var>field</var>
              is the text field to extract the substring from.</p>
            <p><var>position</var> is the
              starting character position of the substring. The first character in a string is position 1.
              If the position is negative, the position is relative to the end of the string. A position
              of -1 is the last character.</p>
            <p><var>len</var> is the number of characters to
              return. If the length is 0, the output is an empty string. If the length is negative, the
              function returns null. This parameter is
              optional.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>substr(Account_Id,13,3)</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>title</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 "> Returns the string with the first character of every word in uppercase and the other
            characters in lowercase.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>title(<var>field</var>)</code>
            </p>
            <p><var>field</var> is the text field to
              apply title case
              to.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>title(Opp_Name)</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>trim</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Removes the specified characters from the beginning and end of a field value. If no
            string is specified, it removes the spaces from the beginning and end of a string.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>trim(<var>field</var>,
         [<var>valueToBeRemoved</var>)]</code>
            </p>
            <p><var>field</var> is the text
              field to remove the specified substring from.</p>
            <p><var>valueToBeRemoved</var> is
              the value removed from the string. This parameter is optional. If unspecified, the
              transformation removes the trailing
              spaces.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>trim('  Spaces Before and After  ')</code></pre>
          </td>

        </tr>
        <tr class="">
          <td data-label="String Function" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e47 ">
            <code>upper</code>
          </td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e50 ">Returns the string with all characters in uppercase. If the string is null, the result
            is null.</td>

          <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d112321e53 ">
            <p>
              <code>upper(<var>field</var>)</code>
            </p>
            <p><var>field</var> is the text field to
              convert to
              uppercase.</p>
            <p>Example</p>
            <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>upper(First_Name)</code></pre>
          </td>

        </tr>
      </tbody>
    </table>

- **[Notation for String Formulas](https://help.salesforce.com/s/articleView?id=data.c360_a_batch_transform_string_notation.htm&release=264.0.0&type=5)**  
    If you manually type your formulas, use single quotes `‘` for string literals and double quotes `“` for joined fields with dot notation or reserved keywords.
- **[Reserved Keywords in Formulas](https://help.salesforce.com/s/articleView?id=data.c360_a_batch_transform_string_keywords.htm&release=264.0.0&type=5)**  
    Batch data transforms have reserved keywords that need special handling when manually writing formulas. Use double quotes “ when referencing fields that share a name with reserved keywords. To avoid cross-referencing your field names with this list, the best practice is to use double quotes around all field names.