KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Querying Rich Text fields
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: August 26, 2010

In 4D v12, when using the new Rich Text feature, you will notice that the actual contents of the text fields will change. Specifically, HTML SPAN tags will be added to the content.

Here are three solutions that can be used to prevent these HTML tags from disrupting the normal operation of Querying and Sorting.

  1. Use the new "Queries and sorts without tags" field property. When you check this property, all tags will be ignored when performing queries, sorting, and when building indexes.

  2. Use the QUERY BY FORMULA command with the OBJECT Get plain text command. As the formula parameter, you would have the OBJECT Get plain text command with the field to query as its parameter. Here is a simple example of what the query would look like:

    QUERY BY FORMULA([Table];OBJECT Get plain text([Table]RichField)="@search string@")


  3. Create a second field that stores the plain text of the field containing Rich Text. For this option, you could simply add code to the trigger of the table and use the OBJECT Get plain text command to save the plain text into the second field. Here is a simple example of what this code would look like:

    [Table]PlainField:=OBJECT Get plain text([Table]RichField)