In a company, order numbers are stored in a format like ORD-458921. The manager wants to create a short tracking code using only the last three digits of the order number.
However, Salesforce formulas cannot directly read text from right to left. To solve this, you can use the REVERSE() function.
First, reverse the order number so the last digits come to the front, then use the LEFT() function to pick the first three characters, and finally reverse it again to get the correct digits.
This way, from ORD-458921, you can easily extract 921 using a formula, which would otherwise be difficult to achieve.
In this article, we will learn about how to use the REVERSE() function in Salesforce with practical examples.
What is the REVERSE() Function in Salesforce?
The Salesforce REVERSE() function is one of several TEXT functions available in Salesforce that perform text operations on fields.
As its name refers to REVERSE, the Salesforce REVERSE function reverses the order of the characters in a provided text string. The function takes only one argument in the REVERSE function, that is, the text that we want to reverse.
Below is the syntax of the Salesforce REVERSE function:
REVERSE(text)Here, the text parameter specifies the string we want to reverse.
How to REVERSE() Text Value in Salesforce
The following steps show how to use the REVERSE function to reverse a string value in Salesforce.
- Click the Setup icon in the top right corner of the page to access Salesforce Setup.
- Select Object Manager from the nav bar.

- Select the object in which you want to create the formula field to reverse the text value. Here I have selected the Campaign object.

- Select Fields & Relationships. Next, select New.

- Select “Formula“ as the field type. Click Next to proceed.

- Enter Field Label: Entry Code (the Field Name auto‑fills), and choose Text as the return type, then click Next.

- In the formula editor, choose TEXT from the function category and insert the REVERSE function.
REVERSE(RIGHT(Name, 5))Here is a detailed explanation of the code:
- We use the Salesforce RIGHT() function to extract the specified number of characters from the end of the text. In this case, I specified the text string as ‘Name’ i.e. Campaign Name, and the number of characters to be removed as 5.
- After that, we passed the result of the RIGHT() function to the REVERSE() function, so that it reverses the order of the characters we extracted from the text string.
- Click Check Syntax to confirm there are no errors.
- In addition, you can enter the “Description”, and “Help Text” if you want. You can also manage the blank fields. Click the “Next” button after that.

- Select the appropriate field’s security level, then check the box beside ‘Visible’ to make it visible to everyone. Click Next.

- Select the Page Layout Name for which the formula field is to be stated. Click Save to save the formula field.

Once the formula field is created, you can use the formula field. Let’s see an example:
- Open the “Campaign” object, create a new campaign with the “Campaign Name” field, and save it.
- After saving, go to the campaign details; there you will see the “Entry Code” field, which shows the result of the REVERSE function.
Let’s deeply understand this example:
Imagine you have created a campaign with the name “Winter Conference” and save it. The formula will execute and return the entry code as “ecner”. This formula effectively reverses the last five characters of the campaign name.

With this, we have learned how to use the REVERSE() function in Salesforce.
Conclusion
In a nutshell, we have learned about the Salesforce REVERSE function which returns the text string in reverse order. Moreover, we have learned the syntax and its practical examples.
You may like to read the following articles:
- LEN Function in Salesforce | How to calculate length of a text string in Salesforce
- SUBSTITUTE Function in Salesforce | Replace Values in Salesforce Formula Field
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.