2

I'm trying to create a validation rule that prevents users from having line breaks in a richtext field. Here's what I have:

Error condition formula: REGEX(Manual_Step_Description__c,"\n")

I want to prevent this:

"Install the Smart vCard AppExchange app, and drag the buttons onto the contact page layout.

Create the context menu item "Export as vCard" in the Contacts grid and point it to the vf download page"

Should be this:

"Install the Smart vCard AppExchange app, and drag the buttons onto the contact page layout. Create the context menu item "Export as vCard" in the Contacts grid and point it to the vf download page"

Appreciate any help, thanks.

1
  • did you try escaping like \\\n Apr 9, 2017 at 1:27

1 Answer 1

2

Unfortunately through formula, line break in the text cannot be identified.

There is a idea Validate line breaks around this. You can vote for this idea.

Otherwise, through apex coding you can do this like below:

String str = [Select RichTextAreaField__c from Dealer__c where Id = '<recordId>'].RichTextAreaField__c ;

System.debug('str=' + str);

if(str.contains('<br>'))
{
    System.debug('line break found');    
}
else
{
    System.debug('no line break');
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .