Print this page

LEN Function returning incorrect results

Knowledge Article Number 000240417
Description When using the LEN Function to count the number of characters in a text string that has line breaks, the count will not equal the number of characters and spaces entered.

Steps to Reproduce:

1. Create a Long Text Area field and a Number field on the Account object
2. Create a workflow rule that updates the number field based on the number of characters in the Long Text Area field. Use this formula:
3. Create an Account record with a value on the Long Text Area that contains a line break. 
4. Notice that the Workflow Rule update the number field counts additional 2 characters for each line break. 

Resolution This is working as designed. For Long Text Area field or Text Area field types, a line break is counted as 2 characters.

The reason why it counts 2 additional characters is because Salesforce inserts a Carriage Return and a Line Feed, the system will contain '\r\n' escape sequences to represent new lines.

See AlsoFormula Operators and Functions

promote demote