New line characters and max length of fields.

Salesforce accepts new lines as 1 character via the API and data loads and will store them as 1 character ("\n").


However, upon editing a record in the user interface in Salesforce, even if you don't touch the field in question, any newline characters are automatically converted to 2 character new lines ("\r\n").


Why is this an issue? If you are already near the field size limit, converting the new lines from 1 character ("\n") to 2 characters ("\r\n") will cause an error on saving and prevent you from editing that record - even if you are not editing the affected field.


For example, we ask users to submit a resume in one field and it has 100 new lines in it. The field accepts 5000 characters and Salesforce accepts the total submission at 4950 characters. Then an internal user logs in to approve the submission. The approval fails because the field is automatically converted to 2 character new lines resulting in a total field size of 5050 characters which is over the limit.


This is a known issue in Salesforce:



How does Formstack deal with this?

On Long Text area and Text Area fields, if the content contains new Line characters, then we count new lines as 2 characters and validate input against the fields maximum length as such. For example, if a field has a maximum length of 1000, and the user has 5 new lines in the content, then the effective field limit is now 995 characters.

This allows these records to be subsequently edited in Salesforce.

Was this article helpful?
2 out of 3 found this helpful



Article is closed for comments.