Search code examples
azure-logic-appsazure-logic-app-standard

Convert report JobFailureCode name Succes with Green and Failed with Red


Fairly new to Logic Apps and not familiar with all the functions. I created a simple Logic App that will check Backup of VMs on Azure and produce the report in formatted fashion.

I am getting what I want but there is requirement of cosmetic change where I want to get Colum Name "JobFailureCode" if Success background color should be Green or Failed with Red. can you please some one guide me what and how to achieve this? enter image description here and Out put I am receiving in mail enter image description here


Solution

  • For testing purpose, I am using static values in a variable and then adding the HTML template data in Compose, you can also use Create HTML table action.

    I am using below HTML template in Compose action to set the background color to either green or red. You can modify the template based on your requirement before invoking the send email action.

    <table border="1">
      <thead>
        <tr>
          <th>Name</th>
          <th>JobFailureCode</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>@{items('For_each')['Name']}</td>
          <td style="background-color:@{if(equals(items('For_each')['JobFailureCode'], 'Success'), 'green', 'red')}">
            @{items('For_each')['JobFailureCode']}
          </td>
        </tr>
      </tbody>
    </table>
    

    enter image description here

    If JobFailureCode is Success.

    enter image description here

    If JobFailureCode is Failed.

    enter image description here