Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

HTML to Plain Text Conversion Issue

(0) ShareShare
ReportReport
Posted on by 31

Hello,

I have been working on a custom workflow where I move the content of an email description field to a case description field, as I effectively convert an email to a case. Have had the common issue where this then originally comes back in HTML formatting with endless tags which then make the case field impossible to read.

With Jason Lattimer's magnificent string workflow solutions, I have converted the field content so it would read something like "Dear Person, <br> Here is my email <br> from Person". His workflows leave in line breaks deliberately, but is there any simple way I could then turn this into:

"Dear Person

Here is my email

from Person"

Could I find and replace the "<br>" to something else for example that would force this? I had followed this description but it just replaces the <br> with double spaces, rather than forcing new lines..

https://community.dynamics.com/crm/b/meganwalker/posts/removing-html-from-email-description-record-creation-rules

Any help would be most appreciated! I am rather new to Dynamics!

Thanks,

Jon

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Hello,

    Do you mean that you've downloaded the string solution zip file and don't know what to do next?

    To install the solution, go to Settings > Solution > Import, and then it opens up a wizard which walks you through this process. Once that's complete, you'll see the CRMStringWorkflowUtility in All Solutions.

    Then, under Settings > Process, make a new Process. It's just making a workflow for the Email entity, so when I get a new email enters the system that matches certain criteria, the workflow runs. In my setup, I have deliberately have an email "Set Regarding" the case in question. This is so that I can also access the related record on the Case entity. My specific workflow had three steps:

    1. Copy the body of the email into the case description.

            That is, "Add Step" > "Update Record" and updating the record called "Regarding (Case)" because, as I say, the Email is ALREADY set regarding the case. 

            Then in the "Update Record" template for the Case, updating the "Description" field with the {Description(Email)} value from the dynamic values dropdown.

    2. Apply the "Remove HTML" custom step to the Description field of the Case

             "Add Step" > LAT.WorkflowUtilities.String (2.3.0.0) > Remove HTML

             Enter {Description(Regarding (Case))} from the dynamic values dropdown as the required Input on this custom step

    3. Then this new string becomes available in the dynamic values dropdown (right at the bottom), so update the case record with the converted string

             "Add Step" > "Update Record" (same record as before, called "Regarding (Case)"

             Update the description field again, with the HTML Removed String(...). The ... will just be whatever you have named the previous step in your workflow, where the string conversion occurs.

    Hope that helps and is fairly clear! I haven't used screenshots, but am happy to provide them if my language isn't clear.

    Thanks,

    Jon

  • andrefpc Profile Picture
    5 on at
    RE: HTML to Plain Text Conversion Issue

    Hi jmillsjmills,

    I have the same issue, I'm able to create a case from an email sent to a specific email address but I'm not able to strip the HTML.

    I was wondering if you could assist in the implementation of the Jason Lattimer's string workflow solution.

    I've downlaoded the package but I don't really know what to do with it.

    Thanks in advance.

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Thanks very much again Clofly! That works very well. Much appreciated.

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Thanks very much again Clofly! That works very well. Much appreciated.

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Thanks very much again Clofly! Much appreciated.

  • cloflyMao Profile Picture
    25,208 on at
    RE: HTML to Plain Text Conversion Issue

    Hi jmills,

    Just add a check condition: if the descrption value not equals null and not equals ""(empty).

    function ConvertLineBreaks(executionContext) {
      var formContext = executionContext.getFormContext();
      var val = formContext.getAttribute("description").getValue();
      if (val != null && val != "") {
        var newVal = val.replace(//gi, "\n");
        formContext.getAttribute("description").setValue(newVal);
      }
    }

    Regards,

    Clofly

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Hello Clofly! Hoping you're still around. Is there anything I can add to your JS so that it won't run if the field it's looking for is blank?

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Clofly that is absolutely fantastic! Thank you so much. I really appreciate you walking me through that so simply, and I have managed to get the result I was after.

    Thank you so much again! You're a true legend of the Dynamics world in my view now!

    Regards,

    Jon

  • Verified answer
    cloflyMao Profile Picture
    25,208 on at
    RE: HTML to Plain Text Conversion Issue

    Hi Jmill,

    Yes, please tick the tickbox.

    From your error and screenshot, there is no function called ConvertLineBreaks.

    You're calling a function called ConvertLineBreaks

    pastedimage1575289071547v1.png

    However, my function name is formatDescription.

    pastedimage1575289136413v3.png

    So you should change it to ConvertLineBreaks, that's your own function name.

    Regards,

    Clofly

  • jmillsjmills Profile Picture
    31 on at
    RE: HTML to Plain Text Conversion Issue

    Hello! Thank you so much for your swift reply. Much appreciated!

    Yes - so this is the script error... (and you can see the original description in the background).

    CRM-Screenshot-1.PNG

    This is my form libraries:

    CRM-Screenshot-2.PNG

    I didn't have this tickbox checked, but then I did tick it and it still produces the same script error (having published all customisations).

    error_2D00_02.PNG

    And this is what i have in the web resource content:

    CRM-Screenshot-4.PNG

    Thanks very much! I'm very appreciative of your help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#2
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 53 Super User 2025 Season 1

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 32 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans