Skip to main content



No record found.

Empty Rich Text Fields Validation using Regular Expression in Dynamics 365

Inogic Profile Picture Inogic 23,963

Empty Rich Text Fields Validation

In the pursuit of enhancing data management within Dynamics 365 CRM, we recently integrated a ‘Rich Text Editor Control‘ into the Description field of the Appointment entity, and inserting text into the description, we observed an unexpected behavior. Upon exporting the data from Dynamics 365 CRM, we noticed that the Description field stored the text along with HTML tags. Surprisingly, even when we cleared the text from the Description field, the HTML tags persisted in the system. This discrepancy became evident when attempting to fetch records with empty Description fields, as the presence of HTML tags prevented these records from being retrieved. Additionally when we wanted to validate if a field of a record Is blank then this discrepancy resulted in inaccurate validation.

In this blog post, we delve into the intricacies of validating whether a Rich Text field truly contains a value using regular expressions in C#.

Let’s consider a use case scenario where a user inputs the word “test” into this Description field. What exactly happens behind the scenes within the system?

Upon entering “test” into the Description field, the system undergoes a process of data storage and representation. Interestingly, the seemingly straightforward input of “test” is transformed into a structured format within the system. Specifically, it is stored as:

<div class=”ck-content” data-wrapper=”true” dir=”ltr” style=”–ck-image-style-spacing: 1.5em; –ck-inline-image-style-spacing: calc(var(–ck-image-style-spacing) / 2); –ck-color-selector-caption-background: hsl(0, 0%, 97%); –ck-color-selector-caption-text: hsl(0, 0%, 20%); font-family: Segoe UI; font-size: 11pt;”><p style=”margin: 0;”>test</p></div>

Please refer to the below screencap for reference,

Empty Rich Text Fields Validation

In case the user clears the content from the Description field, ostensibly rendering it empty. However, behind the veil of apparent emptiness lies a nuanced reality within the system’s data storage mechanism.

Upon clearing the Description field, the system orchestrates a subtle yet significant transformation. Although visually devoid of content, the field is meticulously stored as:

This was originally posted here.


*This post is locked for comments