function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raj R.Raj R. 

How to create a formula field to only get a substring of the record Name?

Hi,

We have record names that have a structure similar to below. I wanted to see what is a good way i could use a formula (text) field that autopopulates a substring into a particular field. Basically, i want to take the bolded substring below and put it into it's own field via formula (text).

Example record names:
  • Text1 - Text1A- Name - Text1B
  • Text2 - Text2A - Name - Text2B
  • Text3 - Text3A - Name - Text3B
The custom formula (text) field can be called customField

Logic:
customField = Name
Best Answer chosen by Raj R.
sanket supe 22sanket supe 22

Hi,

Try this.. 
You can use the MID() function.
Returns character from the middle of a text string, given a starting position and length

Its worked for me..I created same scenario and got the Substring as a "Name"

MID( YourfieldNameHere , 16, 5)

Syntax :  
MID(text, start_num, num_chars)

 : Choose best answer if it working good.
Thanks!

All Answers

sanket supe 22sanket supe 22
Try this..

Data Type Formula

LEFT(Record_Name_Field__c,Find("-", Record_Name_Field__c)-1)

Sub in your actual field name.
 
Raj R.Raj R.
Hi Sanket, that only returns the first text1 (or text2 or text3) substring.

I want to return the third substring as in the example record names above. Any other thoughts?
sanket supe 22sanket supe 22

Hi,

Try this.. 
You can use the MID() function.
Returns character from the middle of a text string, given a starting position and length

Its worked for me..I created same scenario and got the Substring as a "Name"

MID( YourfieldNameHere , 16, 5)

Syntax :  
MID(text, start_num, num_chars)

 : Choose best answer if it working good.
Thanks!
This was selected as the best answer