Formatting email notifications in GeoEvent Processor

6711
7
05-29-2014 04:03 AM
BrookeGajownik
New Contributor II
I am trying to format the email-out notifications so they are more readable.  I have over 80 fields I am feeding into it.  Right now the emails spit out something like this:
Name: Randy
because I have it going in as Name: ${CustomerName}. 
I would like to see this:
Name: Randy
but can't figure out how to format it.  I tried basic HTML <B></B> but it did nothing. 
Any suggestions? Is this even possible?
0 Kudos
7 Replies
RJSunderman
Esri Regular Contributor
Hello Brooke -

Sorry for the delay in getting back with you.  I've confirmed, unfortunately, that the adapter and transport behind the Send an email outbound connector will not accept HTML mark-up ... so you will not be able to add formatting to the e-mail messages you are sending out from GeoEvent Processor at current 10.2.x product release.

After speaking with the developer, support for this can reasonably be added, and I have created a work item in our product backlog. I cannot promise that it will make the 10.3 product release, but we will work to see if we can make that happen.

Best Regards -
RJ
0 Kudos
BrookeGajownik
New Contributor II
Thank you so much RJ!  I appreciate you looking into this for me and I look forward to seeing it added to a future release.  Brooke
0 Kudos
KDeVogelaere
Occasional Contributor

I am also interested in HTML mark-up for the outbound connector.  Keep me posted! Katie

0 Kudos
RJSunderman
Esri Regular Contributor

Good news on this ... the Message Formatter (used by the 'Send an Email' outbound connector) was enhanced at 10.4 to support HTML code. When configuring the output, use the new drop down to select HTML, and e-mail messages you send will display using HTML code you enter into the GeoEvent output connector's message body.

For example:

  • Sending the following event data to GeoEvent (using a 'Receive JSON on a REST Endpoint' inbound connector):
{
  "Customer_Logo": "http://webapps-cdn.esri.com/Apps/MegaMenu/img/logo.jpg",
  "Issue_Header": "Enhance Message Adapter with the ability to handle HTML content",
  "Tech_Advisor": "Ming Zhao",
  "Date_Reported": "June 2, 2014",
  "Customer_Name": "Becks Hybrids",
  "Customer_No": "123-45-6789",
  "Contact_Phone": "1-800-937-2325",
  "Customer_Address": "6767 E. 276th St.",
  "City_State_Zip": "Downs, IL 61736"
}

  • And entering the following HTML code into the 'Send an Email' output's 'Message Body' text box:
<img src=${Corporate_Logo} alt='xxx' width='80'/>
<h1 style='font-family:Segoe, Arial, sans-serif;font-weight: 700;'>${Issue_Header}</h1>
<table style='font-family:Segoe, Arial, sans-serif;font-weight: 400;border-collapse:collapse;'cellpadding='5'>
<tr style='background-color:lightgrey;'>
 <td style='font-weight:600;' width='130px'>Technical Advisor:</td>
 <td width='140px'>${Tech_Advisor}</td>
 <td width='50px'>
 </td>
 <td style='font-weight:600;' width='150px'>Date Reported:</td>
 <td>${Date_Reported}</td>
</tr>
<tr>
 <td colspan='5'>
 <table style='width:100%; border-bottom-style:solid; border-bottom-width:3px; border-right-style:solid; border-right-width:3px; border-bottom-color:#888888; border-right-color:#888888;'>
 <tr style='font-weight:700; font-size:larger; background-color:lightgrey'>
 <td colspan='5'>Customer Information</td>
 </tr>
<tr>
 <td style='font-weight:600;' width='130px'>Customer Name:</td>
 <td width='160px'>${Customer_Name}</td>
 <td width='50px'>
 </td>
 <td style='font-weight:600;' width='150px'>Customer Number:</td>
 <td width='160px'>${Customer_No}</td>
</tr>
<tr>
 <td style='font-weight:600;vertical-align:text-top' width='130px'>Customer Address:</td>
 <td width='160px'>${Customer_Address} <br/> ${City_State_Zip}</td>
 <td width='50px'>
 </td>
</tr>
<tr>
 <td style='font-weight:600;vertical-align:text-top' width='130px'>
 </td>
 <td width='160px'>
 </td>
 <td width='50px'>
 </td>
 <td style='font-weight:600;vertical-align:bottom' width='150px'>Phone:</td>
 <td style='vertical-align:bottom' width='160px'>${Contact_Phone}</td>
</tr>
</table>

  • Should result in a nicely formatted table being sent, via e-mail, to a specified recepient

Capture.png

This was a 10.4 product enhancement.

- RJ

Raleigh_GISGIS
New Contributor II

This is really cool but it looks like it is converting my decimal value into scientific notation. Is there a way to avoid it? I tried mapper processor to map to a string field but that doesn't help. 

A cost value of 45,456,456,456 got converted to 4.5456456456E10 0.0  Any thoughts? 

0 Kudos
RJSunderman
Esri Regular Contributor

GeoNet sent me a message that you were having some trouble using basic HTML tags in the Message Body to simply display certain fields in BOLD. The following worked for me (entered as a single line of text):

<span style='font-weight:600;'>Vehicle ID:</span> ${VehicleID}<br/>
<span style='font-weight:600;'>LastUpdated:</span> ${LastUpdated}

The following also worked for me, using HTML tags rather than CSS Properties:

<strong>Vehicle ID:</strong> ${VehicleID}<br/><strong>LastUpdated:</strong> ${LastUpdated}

– RJ

0 Kudos
RJSunderman
Esri Regular Contributor

Did you perhaps find an answer to your original question on how to BOLD text in your notification message, and re-post to ask about formatting decimal values in more user-friendly formats rather than scientific notation?  GeoNet sent me a message about the former, but looking at the thread this morning, I'm seeing the latter.

In any case, for the question GeoNet is showing now, if the data you are receiving is a high precision value such that Java wants to use scientific notation to represent the value, I think you're stuck with the scientific notation. It's not a question of how to use the MessageFormatter (the adapter used to format an event record prior to sending an email or SMS text message request to an SMTP Server) to reformat a Double value 123456789000 to represent it as 123,456,789,000 rather than 1.23456789E11. The output's adapter does not support string formatting or data type conversion. The only formatting it offers is variable substitution ( e.g. ${VehicleID} ) and HTML / CSS formatting like what I've shown above.

As you've discovered, using a Field Calculator expression such as toString(myValue) to try and convert a Double value to a String simply represents 1.23456789E11 as the string literal "1.23456789E11". Unfortunately the Field Calculator does not support Java code such as String.format("%.0f", myValue) or java.text.DecimalFormat.format(myValue). The processor is only able to interpret a selection of string and mathematical functions for which wrappers have been developed as part of the processor's implementation.

Do you need to handle the cost value as a Double at any point in the GeoEvent Service? You might consider configuring the GeoEvent Definition used by your input to specify costValue be treated as a String, even though the data is arriving as a long integer value. You could use the attribute costValue in your e-mail notification message and (if necessary) use a Field Mapper to explicitly cast the String to a Double by mapping costValue into an event attribute field costValueAsDouble whose data type was Double.

Then you could use costValueAsDouble to perform any calculations you needed. But once cast to a Double I don't think you'll be able to revert a high precision value back to a String in order to avoid the data being represented in scientific notation. Also, using the input's inbound adapter to handle costValue as a String in the first place isn't going to format the string using commas to separate out the thousands portion of the value; it's just going to give you a really long string of digits.

– RJ

0 Kudos