Showing full comments in Gemini’s alert templates

Thoughts to start

A lot of people ask how to get the full comment on an email alert, but there are two trains of thought on this, and both should be considered.

Firstly, if you provide the full comment in an email, then people will not log into Gemini to view the ticket. This may delay any action they might otherwise take, such as updating the status or logging their time for working on the comment. This then means Gemini risks becoming out of date and if this project management / helpdesk solution is not up to date, then can you trust the metrics it shows?

The other side of the coin is that people have to log into Gemini to read mundane irrelevant comments, which could have been ignored if the content was in the email alert in the first place. So you lose 30 seconds of your life reading it only, rather than in full in your email client.

If you do decide to include the full text of the comment, then there is one other important point to raise. If you are using Breeze, the Ticketing from Email aspect to Gemini, then you must be aware that if a comment includes a long email history, this will also be included, in full, in your email alert notification! So, you may want to consider the email truncation options to shorten the email content.

Amending the Template

Firstly, only a Gemini Administrator can edit the template, so if you are an end user, I am afraid you’re stuck with what your business decides; it is not user configurable.

image

Navigate to: Customize | System | Alert Templates as shown in the above screenshot.

All the templates within Gemini are found here. As you can see from the above, there are various Alert Types (covered in another post soon) and these templates can be associated with a projects. This powerful setup allows a project to have its own branded alert templates, but this is again a topic for another post.

Looking at the default template which is shipped with Gemini, adding a comment would look like this:

image

Now looking at the Comments line I can see that you would be dying to know what the comment was to demonstrate. By default, only a snippet of the text is shown, and this maintains the formatting of the email in a nice and consistent way.

So let’s now edit the HTML template for the When Updated alert template, in this case, for All Projects.

image

This form is pretty self explanatory, but for more details, including a full list of injectable fields, see the docs

Scroll down a little way in the Content section and you will come across the snippet of code which is looping through all the changes, which should be notified:

image

The templates are built using Razor syntax so if you know ASP.NET MVC then you should be familiar with the clever coding you can inject in here, if not, there are plenty of online resources to teach you the basics of MVC/Razor.

the @change.Change on line 39 is what writes out the change, but this is already the shortened version, so we need to use another property. There is a FullChange property on the change object, and we can simply replace this Change with FullChange and we see this:

image

So, now all the text is there, however, the astute will notice that there are a couple of <p> tags appearing. This is because the full HTML is shown in this change and there a couple of ways we can address this.

Render the HTML

Firstly, we can get the HTML to be rendered, rather than just displayed. Those familiar with Razor will already know the solution to this, we use @Html.Raw(…..) to get Razor to render the HTML. We change the line @change.FullChange to @Html.Raw(change.FullChange)

image

However, if there was a long complex email history as part of the comment this could become very messy, so use with caution!

image

You can see that a comment with formatting has been added, but even a simple comment has taken up a lot of lines in the email.

Convert the HTML

Rather than try and render all the HTML, we could strip it out completely. Instead of the Html.Raw(…) you can use one of the secret built in functions to convert the HTML text to plain text. It is not a perfect representation, but it does the job.

@Countersoft.Foundation.Utility.Helpers.HtmlHelper.ConvertHtmlToText2( change.FullChange )

image

However, while all the text is there, the formatting is gone. This is to be expected as we said convert it to plain text! But we can now add some code to put some html line breaks in, which should then help our readability a little more.

So we now have:

@Countersoft.Foundation.Utility.Helpers.HtmlHelper.ConvertTextToHtmlNewLine(
         Countersoft.Foundation.Utility.Helpers.HtmlHelper.ConvertHtmlToText2( change.FullChange ?? string.Empty ))

This results in:

image

A little better, but it is plain text with line breaks.

So it is a trade off that you will need to weigh up and see which works best for you.

Please let us know in the comments what you think and head over to countersoft.com to see more about Gemini.

Comments