8 Replies Latest reply on Mar 31, 2010 4:22 AM by AdamWilden

    HTML emails: Formatting/replacing text via Caluclations?

    Expert


      OK - Last post for a while (Honest!).

       

      Like many, we use html email and create customer emails using reminders.  These usually consist of html and usually reference a few placeholders.

       

      The obvious problem with this is that the embedded text shoved into the html loses its formatting (primarily line breaks).

       

      We've experimented with using html fields but not really found a way around this (let me know if anyone else has!).

       

      At the moment a lot of support staff are simply typing <BR> at the end of each line so that when it is imported into, say. a reminder it keeps it's formatting.

       

      I was wondering if this could be automated via a calculation?  Either formatting teh string or even maybe replacing something simpler to type such as "..."?

       

      Or if anyone has any other good ideas.

       

      Thanks folks.

        • 1. Re: HTML emails: Formatting/replacing text via Caluclations?
          aparker Employee

          Hi Adam,

           

          I have used calcualtions to provide HTML formatting to attributes which have then been displayed on the portal and in principal this can be done in a similar way for an email, however, I think there is a potential banana skin that we would have to get around. What you don't want to do is to go into the Reminder object and make the body text field a calculated field as this would most likely cause lots of problems. Apart from anything else, you would need to make every reminder calculated.

           

          What you might be able to do, however, is to create a new attribure that builds the HTML and text and then reference that as a value type when creating the reminder action. The calculation function I used is shown below. It's the string concatenation syntax that's relevant for what you want to do.

           

          import System
          static def GetAttributeValue(Article):
          Value = String.Format("<h6>{0}</h6><h3>{1}</h3>",Article.Title,Article._Description)
          return Value

           

          Andy

          1 of 1 people found this helpful
          • 2. Re: HTML emails: Formatting/replacing text via Caluclations?
            Stu McNeill Employee

            To get the new lines in you need to do what Andy has already suggested to concatonate the text but add an extra bit of jiggery pokery at the end:

             

             

            import System
            static def GetAttributeValue(Article):
             Value = String.Format("<h6>{0}</h6><h3>{1}</h3>",Article.Title,Article._Description)
             return Value.Replace(Environment.NewLine, "<br>")
            
            
            

            The String.Replace() method will simply replace all new lines with whatever text is in the quotes, in this case "<br>".

             

            This can all then be used on the Reminder Body attribute in the automatic action.

            • 3. Re: HTML emails: Formatting/replacing text via Caluclations?
              Expert

              Fantastic - as Andy suggests we already have a formatted-text field in place we can use.  I've tested the calulcation against it, pulling in a couple of fields and replacing the newline char and all looks very promising.

               

              I can't update the process until tonight, but it looks like this may be one of the most useful bits of information I've seen here yet.

               

              Many thanks both.

              • 4. Re: HTML emails: Formatting/replacing text via Caluclations?
                smiddleton Expert

                Hi Adam,

                 

                I have setup our system to use HTML formatted messages as well.

                 

                Possibly a simpler solution for you would be to do as I have done.

                 

                At each status within the system I have the Add Note action there is a following automatic Add Reminder.

                 

                This reminder contacts HTML formatting text ie a logo and page size restriction.

                 

                As part of the code when I reference a placeholder which is multi-line I add the tags <pre> and </pre> at the start and end respectively.

                 

                This causes the reminder to get populated with the notes text or any possible collection object and keeps the text formatting intact.

                 

                Does require a little more work in the process designer but allows for highly configured outbound mail.

                 

                 

                 

                As a side note if were still wanting your analysts able to set a reminder (with above mentioned formatting) you could create a new collection object much like Notes with a date time field to select send date and then have you Automatic Add Reminder use a calculation to set the send date to whats been added in the previous vindow.

                 

                Or just let your support staff know that by typing <pre> at the start of the message and then </pre> at the end all text formatting inbetween will be kept on the outbound message.

                • 5. Re: HTML emails: Formatting/replacing text via Caluclations?
                  Expert

                  Doh!   Why have I never heard of this tag?!

                   

                  Thanks Stephen - we also populate reminders in the same way as you so this should prove useful, especially as it preserves spaces.

                   

                  Going to do some investigating later this week, but I have a few options now and have some other ideas of where each of these may also be very useful.

                   

                  Cheers.

                  • 6. Re: HTML emails: Formatting/replacing text via Caluclations?
                    smiddleton Expert

                    Glad I could help!

                     

                    It's a tag I came across years ago when playing with HTML but it isnt that well known for some reason.

                     

                    Possibly because most web site designers prefer to use <BR> as it gives greater control over where a line break appears.

                    • 7. Re: HTML emails: Formatting/replacing text via Caluclations?
                      ITSMMVPGroup

                      Does anyone else agree that HTML formatted is still a bit of a black art with LDSD and that an ER raised for it to properly support placeholders is worthwhile?

                      • 8. Re: HTML emails: Formatting/replacing text via Caluclations?
                        Expert

                        Many thanks everyone,

                         

                        We are now more or less where we want to be.

                         

                        We decided to go with <PRE></PRE> tags as we can use this on existing fields - the replace calculation functionaility we have other plans for...

                         

                        An ER would be good, though this is an area where we *can* get a result (even though work is required - generally I'd like to see better formatting available in all text fields) rather than some areas where we don't yet have solutions - so I'm putting my weight behind those 

                         

                        I've attached a screenshot of our resolution html, as an example of what we are doing.  I suspect others are already there but as I would have found this useful myself, it might help others who are just starting. Excuse my poor HTML.

                         

                        We notify users of resolution via a reminder that copies in 3 fields via placeholders:

                         

                        • The original call details - {Description}
                        • Contact wording for the resolution group (this can differ so we added a field to the Support group Object and Window) - {CurrentAssignment/Group/_ContactWording}
                        • Resolution details - {Resolutions/Description}

                         

                        The attached bmp shows what the reminder html looks like in a browser, what the customer sees in a typical call resolution, and the html itself.

                         

                        (We show the Incident number in the email subject line (we include "Update" so customers can reply and unresolve the call within 24 hours): "Update: Incident Number {Id} has now been resolved.")

                         

                        We've used the same sort of thing on reminders for Notes and Assignments.

                         

                        Thanks again folks.