Skip to main content
March 23, 2024
Solved

Send Email Smart Service

  • March 23, 2024
  • 4 replies
  • 0 views

Hi Community,

I am just trying all scenarios related to send email smart servce though my environment.

I need to add process report to body of the email. Could you help me 

    Best answer by tejak2639

    Hi
    As per my doings,
    We can't directly call a rule in mail
    So we have to do through HTML.


    1.Create a HTML template with tables (refer html format of how to create tables)

    2.Get the report data by using queryprocessanalytics

    3.Loop the data for HTML code.

    4.When configuring email select email template and select the template you created.

    Refer the code:-
    concat(
    "
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
    }
    </style>
    </head>
    <body>
    ",
    a!forEach(
    items: ri!queryprocessanalyticsData,
    expression: "
    <table style=width:100%>
    <tr>
    <th>C0</th>
    <th>C1</th>
    <th>C2</th>
    <th>C3</th>
    </tr>
    <tr style="&char(34)&"text-align:center"&char(34)&">
    <td><a href="&ri!links[fv!index]&">"&fv!item.C0&"</td>
    <td>"&fv!item.C1&"</td>
    <td>"&fv!item.C2&"</td>
    <td>"&fv!item.C3&"</td>
    </tr>
    </table>"
    ),
    "</body>
    </html>"
    )

    4 replies

    tejak2639
    tejak2639Answer
    March 23, 2024

    Hi
    As per my doings,
    We can't directly call a rule in mail
    So we have to do through HTML.


    1.Create a HTML template with tables (refer html format of how to create tables)

    2.Get the report data by using queryprocessanalytics

    3.Loop the data for HTML code.

    4.When configuring email select email template and select the template you created.

    Refer the code:-
    concat(
    "
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
    }
    </style>
    </head>
    <body>
    ",
    a!forEach(
    items: ri!queryprocessanalyticsData,
    expression: "
    <table style=width:100%>
    <tr>
    <th>C0</th>
    <th>C1</th>
    <th>C2</th>
    <th>C3</th>
    </tr>
    <tr style="&char(34)&"text-align:center"&char(34)&">
    <td><a href="&ri!links[fv!index]&">"&fv!item.C0&"</td>
    <td>"&fv!item.C1&"</td>
    <td>"&fv!item.C2&"</td>
    <td>"&fv!item.C3&"</td>
    </tr>
    </table>"
    ),
    "</body>
    </html>"
    )

    March 27, 2024

    concat(
    "
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
    }
    </style>
    </head>
    <body>
    ",
    a!forEach(
    items: rule!RF_getProcessREportData(),
    expression: "
    <table style=width:100%>
    <tr>
    <th>C0</th>
    <th>C1</th>
    <th>C2</th>
    <th>C3</th>
    </tr>
    <tr style=" & char(34) & "text-align:center" & char(34) & ">
    <td>" & fv!item.C0 & "</td>
    <td>" & fv!item.C1 & "</td>
    <td>" & fv!item.C2 & "</td>
    <td>" & fv!item.C3 & "</td>
    </tr>
    </table>"
    ),
    "</body>
    </html>"
    )

    In the rule I have this code  

    a!queryProcessAnalytics(
      report: cons!RF_PROCESS_REPORT,
      contextProcessModels: cons!RF_PROCESS_MODEL,
      query: a!query(
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
      )
    ).data

    Result is like this

    tejak2639
    March 27, 2024

    Hi
    Use the forloop after </tr> before <tr style=" & char(34) & "text-align:center" & char(34) & "> and check the data is there in process report or not