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.

  • did you try escaping like \\\n – night crawler Apr 9 '17 at 1:27
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');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.