All Articles

Email Error Handler Subprocess with HTML Template

Errors are going to occur in your process and how you catch them is critical. The processes described within the knowledge article will outline setting up a subprocess that can be reused and will send an easy to read and to interpret HTML email. There will be two error handlers that will be reviewed. The first will be for catching single error points. These are simpler to setup and useful for low-volume runs, because it’s less likely that errors will occur in multiple spots. The second error handler will be designed for catching errors in multiple stops, all errors will populate a cache, and at the end of the process all errors will be grouped together to send one email.

Example Email

Figure 1. Email example

Basic Email Error Handler

Both error handlers operate by setting dynamic document properties before the documents are loaded into the subprocess. This setup allows any document type (XML, JSON, database, etc.) to be loaded into the subprocess and the error will be processed normally.

Process Overview

Figure 2. Main process Set Properties and (sub) Error Handler.

Subprocess Overview

Figure 3. Error Handler subprocess without cache.

The Set Properties shape preps the data that is being loaded into the subprocess by populating dynamic document properties or dynamic process properties. The DDP_ErrorMessage parameter will often be set with a try/catch error message and a mixture of static and dynamic error messages. The DDP_DocumentID is often set with a mixture of static and dynamic content. An example of the static parameter could be “Salesforce Case: ” and the dynamic content could be “1232”, which is populated from a profile element. The To Address and From Address would be best set by using Process Properties. To use Process Properties, set the DPP_ToAddress and DPP_FromAddress that is in the main process with a Process Property. This setup allows for different environments (i.e. dev and prod) to have different To Address. These Process Properties can be set by extensions and as email addresses need to change, can be updated without have to redeploy the process.

Once the dynamic document properties or dynamic process properties are set, the data is loaded into the subprocess and the first message shape is executed. This message shape will be used to create the repeating elements within the HTML table. If more information needs to be captured within the email, then set additional dynamic document properties in the Set Properties shape and add additional <dd> lines within the repeated elements below (i.e. <dd>Document ID: Case Number: 321321</dd>).

Coding block 1. An example of 1 element that will repeat.

<tr>
  <td>
    <dl>
      <dd class="bold">Error in Salesforce Case to Jira Issue Process</dd>
      <dd>Error occurred at 07/03/2020 6:05:11 AM</dd>
      <dd>Document ID: Case Number: 321321</dd>
      <dd>Error Message: Error creating Jira Issue because server is down.	</dd>
    </dl>
  </td>
</tr>

The data is populated within the message shape by using the dynamic document properties that were set in the main process. The message shape will combine all documents into one document. Finally, each error will be outlined with a red bar on the left within the email.

First Message Shape

Figure 4. First message shape

The next message shape will populate the html code that comes before and after the repeating elements. There will be additional parameters set within this message shape that will populate the company name and execution Id, which is used for the link, within the email. Next, the Set Properties shape dynamically sets properties for the email connector (To Address, From Address, Body, and Subject).

Second Message Shape

Figure 5. Second message shape

Finally, an email connector is setup. Within the email operation, the disposition will be set to inline, and the Content Type set to text/html. The Set Property shape will populate the rest of the email operation.

Error Handler Subprocess with Cache

The Error Handler subprocess is very similar to the one outlined above, but some complexity is added so that errors can be catch in multiple places within the process and sent out in one email. This error handler has two subprocesses. The main process will be setup with three branches. The first branch will setup global dynamic process properties. This setup can be useful for setting parameters in one spot. The second branch will start with a try/catch that catches all errors so that branch three will always be able to be executed. Finally, the third branch will check if any errors occurred with a decision shape that checked if an error flag was flipped and, if so, the error handler subprocess will be executed.

![Main Process With Cache]](main-process-with-cache.png)

Figure 6. Main process with cache

Along branch two, when errors occur, they will be loaded into the first error handler subprocess, which loads data into a cache. The error cache subprocess will have dynamic document properties set before the documents enter the subprocess. One of these properties will be an error flag and will be used to execute the error handler that is on branch 3. Within the error cache subprocess there is a map that is used to populate a canonical profile that gets loaded into a cache. If there is additional information that is required, feel free to add additional fields to this canonical profile.

Once branch two has been executed, the decisions shape on branch three will check if any errors occurred. If errors did occur, then the error handler subprocess is executed. Within the error handler subprocess it starts with a Remove From Cache shape and after that populated the message shapes similar to how the simple error handler subprocess was described.

Error Handler Add to Cache Subprocess

Figure 7. Error Handler Add to Cache subprocess

Map with Dynamic Document Properties

Figure 8. Map with dynamic document properties

Error Handler Subprocess with Cache

Figure 9. Error Handler subprocess with cache

Below is an example of the fully compiled and populated html that would be emailed.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html" charset="us-ascii" />
    <meta name="viewport" content="width=device-width" />

    <style media="screen" type="text/css">
/* -------------------------------------
        GLOBAL
------------------------------------- */

      * {
        font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;
      }

      body {
        height: 100%;
        margin: 0;
        background-color: #efefef;
      }

      dl {
        border-left: solid 3px #cc0000; /* Sets red bar on the left */
        padding-left: 10px;
        margin-bottom: 10px;
        margin-top: 0px;
      }

      .bold {
        font-weight: bold;
      }

      dd {
        padding: 0;
        margin: 0;
      }

      a.button {
        text-align: center;
        background-color: #033d58; /* Button color */
        border: none;
        color: white;
        padding: 12px 32px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        border-radius: 4px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        display: inline-block;
        color: white;
        width: 300px;
      }

/* -------------------------------------
        BODY TABLE
------------------------------------- */

      .body-wrap {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: #efefef;
        padding: 0;
        vertical-align: top;
        border: none;
      }

/* -------------------------------------
        MAIN ERROR TABLE
------------------------------------- */
      .container {
        display: block;
        max-width: 600px;
        margin: 0 auto auto auto; /* Makes it centered and aligned to top*/
        clear: both;
        padding: 15px;
        background-color: #ffffff;
        border: 0;
      }

/* -------------------------------------
        TYPOGRAPHY
------------------------------------- */

      h1 {
        line-height: 1.1;
        margin-bottom: 15px;
        color: #000000;
        font-weight: 500;
        font-size: 20px;
        margin-top: 15px;
        margin-left: 0;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }

      body {
        color: #000000;
        font-size: 15px;
        font-weight: 400;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }
    </style>

    <!--[if gte mso 10]>
      <style>
         /* Style Definitions for Microsoft Outlook*/

        body {
          font-size: 12px;
        }

        h1 {
          text-align: left;
          margin-left: 1.5em;
        }

        .body-wrap {
            mso-margin-top-alt:auto;
            mso-margin-bottom-alt:auto;
            mso-padding-alt:0in 0in 0in 0in;
        }

        .container {
          mso-style-name:"Table Normal";
          mso-tstyle-rowband-size:0;
          mso-tstyle-colband-size:0;
          mso-style-noshow:yes;
          mso-style-priority:99;
          mso-style-parent:"";
          mso-para-margin-bottom:0;
          mso-pagination:widow-orphan;
          font-size:12.0pt;
          font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;
          mso-yfti-tbllook:1184
          mso-cellspacing: 0;
          mso-padding-alt: 2pt 2pt 4pt 0pt;
          mso-style-unhide:no;
          mso-table-top: 0pt;
          mso-table-anchor-verticle:margin;
          }
      </style>
    <![endif]-->
  </head>

  <!-- BODY -->

  <body>
    <table class="body-wrap">
      <tr>
        <td class="body-wrap">
          <div align="center">
            <table class="container" style="border-top: 5px solid rgb(0, 118, 179)" cellpadding="0">
              <tr>
                <td>
                  <h1>Dell Boomi AtomSphere Error Messages for Company Name</h1>
                </td>
              </tr>

              <tr>
                <td>
                  <dl>
                    <dd class="bold">Error in Salesforce Case to Jira Issue Process</dd>
                    <dd>Error occurred at 07/03/2020 6:05:11 AM</dd>
                    <dd>Document ID: Case Number: 123123</dd>
                    <dd>Error Message: Error Updated Case because internal Id is a required field.</dd>
                  </dl>
                </td>
              </tr>

              <tr>
                <td>
                  <dl>
                    <dd class="bold">Error in Salesforce Case to Jira Issue Process</dd>
                    <dd>Error occurred at 07/03/2020 6:05:11 AM</dd>
                    <dd>Document ID: Case Number: 321321</dd>
                    <dd>Error Message: Error creating Jira Issue because server is down.</dd>
                  </dl>
                </td>
              </tr>

              <tr>
                <td style="padding-top: 10">
                  <div align="center">
                    <!--[if mso]>
                      <v:roundrect
                        xmlns:v="urn:schemas-microsoft-com:vml"
                        xmlns:w="urn:schemas-microsoft-com:office:word"
                        href="https://platform.boomi.com/AtomSphere.html#reporting;accountId=<accountId>;executionId=<executionId>"
                        style="height: 50px; v-text-anchor: middle; width: 350px; mso-position-horizontal: center"
                        arcsize="10%"
                        fillcolor="#033D58"
                        strokecolor="#033D58"
                      >
                        <w: anchorlock/>
                        <center style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial">
                          Boomi Platform Execution Log
                        </center>
                      </v:roundrect>
                    <![endif]-->
                    <![if !mso]>
                    <a
                      class="button"
                      href="https://platform.boomi.com/AtomSphere.html#reporting;accountId=<accountId>;executionId=<executionId>"
                      target="_blank"
                      >Boomi Platform Execution Log</a
                    >
                    <![endif]-->
                  </div>
                </td>
              </tr>
            </table>
          </div>
        </td>
      </tr>
    </table>

    <!-- /BODY -->
  </body>
</html>

Article originally posted at Boomi Community.

Published Jan 11, 2021

Developing a better world.© All rights reserved.