Loading

How to retrieve numbers from a Text Field

게시 일자: Sep 27, 2025
상세 설명
A text field sometimes contains numbers, and on occasion these numbers need to be extracted and entered into a separate field. 

This solution will be about extracting numbers from the Subject field on Cases. It can apply to any text field in any object.

 
솔루션
Summary:
You’ll first need to create a text (or number) field to hold those numbers. Secondly, you’ll need to create a record-triggered flow on Cases (or any object that holds the field you want to extract the numbers from) to extract those numbers and update the field you created in the first step

_____________________________________________
Resolution: 
Create a new text (or number) field on Cases where the numbers off the subject will be kept:

Step 1: Go to any Case record and click the gear icon on the top right of the screen and click Edit Object.
 

0069.png

Step 2: Click on Fields & Relationships in the left-hand-side panel, then on the New button:
 

0070.png

Step 3: Select Text (or Number) then click on Next.

Step 4: Give it a name (for the purpose of this article, we’ll call our field Subject Numbers Only), set its length as necessary (up to 255 characters if a text field, 18 digits including the decimals for a number field) and click Next.

Step 5: Make it available to the necessary profiles/permission sets and click Next again.

Step 6: Decide which Page Layouts to have the field on and Save.

_____________________________________________

Create a Record-Triggered-Flow on Cases

Step 1: Click on the Home tab if you’ve just finished with the field, or the Gear icon (top right of the screen), then Setup.
 

0071.png

Step 2: Enter Flow in the Quick Find on the left-hand side, then click the New Flow button.

Step 3: Select Record-Triggered Flow, then Create.
 

0072.png

Step 4: Set the Object to Case and select A record is created or updated in the Trigger the Flow When section.

Step 5: In the Set Entry Conditions section, change the Condition Requirements to Formula Evaluates to True and enter the following formula in the box:

 
OR(
AND(ISNEW(),NOT(ISBLANK({!$Record.Subject}))),
ISCHANGED({!$Record.Subject}))


0073.png

Step 6: Set When to Run the Flow for Updated Records to Every time a record is updated and meets the condition requirements and make sure you select the Fast Field Update box and click Done.

00.png

Step 7: Now, expand the left-hand-side menu (symbol on the left of Select Elements) and click on New Resource.
 

01.png

Step 8: Select Formula.

Step 9: Give it a name (For now, let's call it LenFormula), set the Data Type to Number and its Decimals option to 0.

Step 10: For the formula itself, enter:

 
LEN({!$Record.Subject})

Step 11: Click Done.
 

02.png

Step 12: Click on New Resource again on the left-hand-side and select Variable.

Step 13: Give it a name (for example Counter) and make sure the Data Type is set to Number.

Step 14: Set the Decimals to 0 and the Default to 1 and select the Available for input checkbox and click Done.
 

03.png

Step 15: Back to the canvas, add a Decision and set the outcome like so:

a. Counter less than or equals to LenFormula:
 04.png

Step 16: From this outcome, add an Assignment element.

Step 17: Give it a name.

Step 18: Click in the Variable field and select +New Resource.
 

05.png

Step 19: Select Variable and create a variable of type Text. Let's call it TextVar. No need for a Default value and make sure both Available for input and Available for output are checked and click Done.
 

06.png

Step 20: You should now be back in the Assignment.

Step 21: Set the Operator to Add.

Step 22: Click in the Value field and select +New Resource.

Step 23: This time, select Formula.

Step 24: Give it a name (i.e. NumberTextFormula) and make sure it returns Text.

Step 25: Set the formula to the below and click Done.
 
IF(OR(
/*Check for a digit*/
ISNUMBER(MID({!$Record.Subject},{!Counter},1)), 
/*Check for a decimal point - needs to be in between numbers*/
AND(
MID({!$Record.Subject},{!Counter},1)=".",
ISNUMBER(MID({!$Record.Subject},{!Counter}-1,1)),
ISNUMBER(MID({!$Record.Subject},{!Counter}+1,1)))),
MID({!$Record.Subject},{!Counter},1),NULL)


07.png

Step 26: You should now be back in the Assignment.

Step 27: Add another line to this Assignment by clicking the +Add Assignment button.

Step 28: Set the new line like below

a. Counter - Add - 1

Step 29: The Assignment element should look like this
 

08.png

Step 30: Link this Assignment back to your Decision.

Step 31: Hover over the dot below the Assignment, it should change to a + sign, and click it.

Step 32: Select Connect to element.
 

09.png

Step 33: Click on the + sign on the Decision you created previously and you should see the connection on the canvas.
 

11.png

Step 34: Now, add an Update Records element to your flow in the Default path of the decision to update the triggering Case and update the Text field you created to hold the numbers.

Step 35: Give it a name (for example UpdateCase).

Step 36: The How to Find Records to Update and Set Their Values section should be set automatically to Use the case record that triggered the flow if you created a flow for Fast Field Updates.

Step 37:
Leave the Condition Requirements to Update Record dropdown to None–Always Update Record.

Step 38: In the Set Field Values for the Case Record section, enter the below and click Done.
     

Subject_Numbers_Only__c <-- {!TextVar}

44.png

Note:
If you chose to create a Number field in point 3, the Value in the Update Records element needs to be a formula (let’s call it FinalNumberFormula) like so

 
VALUE({!TextVar})

The Set Field Values for the Case Record section of the Update Records element should now read
 
Subject_Numbers_Only__c <-- {!FinalNumberFormula}

Step 39: Your flow should now look like this:
 

45.png

Step 40: Save and Activate the flow.

You’re now done!

Note:
Please bear in mind that this will only work for newly created/updated Case Subjects. For existing ones, you'll need to manually update the Subject_Numbers_Only__c  (maybe with the data loader), or create a scheduled flow that would run once on the Case object with the same elements as above. 


_____________________________________________
Written by: Eric Praud | Salesforce MVP
Eric is a senior consultant at Epam PolSource and has been working in the Salesforce ecosystem for the past 12 years. He started his Salesforce career as a Salesforce support agent. Like many others, he stumbled across the platform accidentally and hasn’t looked back since. Eric is very active in the Answers community and has been a Salesforce MVP since March 2021


Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content and other materials made available by or on behalf of third parties ("Third Party Materials).  Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third  Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality,  usefulness or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purports to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a “best” answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions.

If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed

 
Knowledge 기사 번호

000396056

 
로드 중
Salesforce Help | Article