Communications notes and emails

In the communications table we have comm_note and comm_email. If the comm type is email, the details go into comm_email otherwise it goes into comm_note. All well and good. A customer of mine has a good reason to want to see the notes in a list. The communication list calls vCommunication. However, if the list only has comm_note in it, they can't see the contents of the email. They don't want to put both in. In old versions of CRM the email contents went into comm_note but this was changed a while back.

So, what I did was to create a dummy field in translations called comm_alldetails and then I altered the view so that instead of comm_note it did a calculated field:

isnull(comm_note, comm_email) as comm_alldetails.

Then in the list I can show the calculated field. All well and good except the email contains HTML tags. So when the email contents are shown and it is an HTML mail from Outlook via plugin, you get unreadable text. So, a few years ago, I put in a SQL function to strip out the HTML on the fly. Now the system has been in use for a good while now and there are lots of communications, the communications list is taking ages to load. Sometimes as much as 30 seconds. Take the HTML stripping code out of the SQL view and it is fine, albeit with SQL.

The customer asked me if it is worth having an escalation that copies the stripped HTML out into a new field. I don't like this approach myself as it duplicates data. Anyone any other ideas? They have SQL 2014 if that helps and they're on 7.3SP3

Thanks.

  • 0

    I think you can do this codelessly using an Interactive Dashboard. You should be able to create a list gadget that will display emails and a record summary gadget that displays fields from the communication record.

    The dashboard could be created either as a 'My CRM' dashboard or as a Company dashboard.

  • 0

    Thank you Jeff,

    This is a different approach.

    Have created a sample and for the users to trial

  • 0

    HI Lee,

    Considering that your view will continue growing, you will find your performance decaying over time if you are using a SQL function. You have a few options:

    1. Optimise the function

    Since I'm not too sure what your function looks like, I'm not too sure how possible this is. You can try and rewrite the function to perform certain logic more efficiently. Keep in mind that SQL can process XML so maybe you can use some of those features to process the HTML. There could also be other logic that is also not very efficient that you could optimise.

    While this is a possible solution, I wouldn't suggest this because it's not necessarily solving the problem, just slowing it down. It is very likely that you will run into a performance issue later in the future.

    2. Parse HTML in Javascipt

    Another solution would be to actually use Javascript to remove the HTML tags. This can be done by placing a Javascript script in the Custom Content field on the list that goes through each cell on the screen, parses the text into HTML, converts it into plain text without tags and then replaces the cell contents with that plain text. This would be much more efficient and more permanent solution since the script will always only parse the cells that are currently visible on the screen. This means that no matter how big your view gets, it will always only parse the 10/20/50/etc emails that are visible in the list on the screen at a given moment.

    The script below should do this. It goes through each cell in the comm_alldetails column and replaces each one with the plain text. You could place this in the Custom Content of your list:

    <script>     $(document).ready(function() {         crm.grids("0").rows().column("comm_alldetails").exec(function(index,currentCell){             // We wrap the cell contents in 

    tags in case the text is not HTML. This prevents

    // jQuery from breaking when it tries to parse text that might not be HTML. var htmlText = "

    " + $(currentCell).text() + ""; // We now use jQuery to parse the string of HTML into an HTML object. We then // use the .text() method to get the HTML object as a plain string without any tags var plainText = $(htmlText).text(); // We then just replace the cell with the plain text $(currentCell).text(plainText); }); }); </script>

    The only drawback to this method is that the view will still return HTML tags in the field, so if you need to use the view in .NET or ASP to do some sort of other processing, you will be getting the string with HTML tags in it and not the plain text version. But you never specified using the view in this way so this solution should work fine.

    I hope that this is somewhat helpful.

  • 0

    Well, that is an alternative approach... I will have a play with that. I didn't consider using the client side API to strip the tags.