Inside my Remote Event Receiver the Current value and the After value for a Rich Text Editor field will be different even if i do not modify the field

john john 946 Reputation points

I have the following Rich Text Editor field inside my sharepoint online with internal name = "ApproverFeedbackandnotesPowerBi":-


and inside my remove event receiver i am checking the Current Value of this field against the After value as follow:-

 public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)  
            SPRemoteEventResult result = new SPRemoteEventResult();  
            using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))  
                    if (clientContext != null)  
                        ListItem currentItem = clientContext.Web.GetList(clientContext.Web.ServerRelativeUrl + "/lists/ApprovalProcess").GetItemById(properties.ItemEventProperties.ListItemId);  
                        if (properties.ItemEventProperties.AfterProperties["ApproverFeedbackandnotesPowerBi"].ToString() != (currentItem["ApproverFeedbackandnotesPowerBi"] == null ? null : ToString())  

now the check will always fails, so when i debug my code i have noted that the currentItem["ApproverFeedbackandnotesPowerBi"] will always have extra html tag (<div class="ExternalClassD7C94EE0628F493686BC675B96532912">), for example, in one case the currentItem["ApproverFeedbackandnotesPowerBi"] =

<div class="ExternalClassD7C94EE0628F493686BC675B96532912">&#128993;Abstain By&#58;- . Comment&#58;-  Nothing was attached..<br>✅Approved By&#58;- . Comment&#58;-...<br><br></div>  

while the properties.ItemEventProperties.AfterProperties["ApproverFeedbackandnotesPowerBi"] =

&#128993;Abstain By&#58;- . Comment&#58;-  Nothing was attached..<br>✅Approved By&#58;-. Comment&#58;-...<br><br>  

so can anyone advice why this is happening? and how i can fix it, so my comparison will work correctly?

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,265 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,051 Reputation points

    You can try to clear the HTML tags in these string values.

    public static string StripHTML(string input)  
       return Regex.Replace(input, "<.*?>", String.Empty);  

    References:How do I remove all HTML tags from a string without knowing which tags are in it?

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.