Can some suggest what is the best way to display a tabular data with coloring on rows in email body via a notification ?
Currently using ncolumntable() for table formation and used default html template in send email smart service for email body.
As the current requirement is to show the data in rows different color based on one of the column data (have some validations ) .I have tried using Ncoulmnstyledtable) , its not working .
Appian version is 16.3.
Discussion posts and replies are publicly visible
Hi Soujanya B (soujanyab0001) i have tried to build a similar type of rule as yours to generate the template having table structure with dynamic data into their cells by considering apply() instead of a!forEach() as you are working with Appian 16.3, please find the source code below:
Parent rule, which is needed to be invoke inside Email body:
"<table style='width:100%' border='1'> <tr bgcolor='blue'> <th>License Number</th> <th>Line Number </th> <th>Last Producing UWI</th> <th>Activity Type</th> <th>LastProduction Date</th> <th>Date of Non-Compliance</th> <th>Days to Non-Compliance</th> </tr> "&apply( rule!PRTRR_CreateEmailBodySectionTable( PRTRR_PipelineList: ri!PRTRR_PipelineList, index: _ ), if( rule!APN_isEmpty(ri!PRTRR_PipelineList), {}, enumerate(1 + length(ri!PRTRR_PipelineList)) ) )&" </table><br></br><br></br> <font color='yellow'>YELLOW </font><legend>-> Inactive Lines Requiring a Decision</legend><br></br><font color='orange'>ORANGE </font><legend>-> Non-Compliance Imminent </legend><br></br><font color='red'>ORANGE</font><legend>-> Non-Compliant Pipelines </legend>"
let's consider the rule input: PRTRR_PipelineList is of type CDT (Array) or Any Type here.
The Child rule which is responsible to form <td> having dynamic content for it's cell let's say: PRTRR_CreateEmailBodySectionTable
concat( "<tr>", "<td>"&index(index(ri!PRTRR_PipelineList, "lineNumber", null()), ri!index, null())&"</td>", "<td>"&index(index(ri!PRTRR_PipelineList, "uwi", null()), ri!index, null())&"</td>", "<td>"&index(index(ri!PRTRR_PipelineList, "activity", null()), ri!index, null())&"</td>", "<td>"&index(index(ri!PRTRR_PipelineList, "lastprod", null()), ri!index, null())&"</td>", "<td>"&index(index(ri!PRTRR_PipelineList, "nonComp", null()), ri!index, null())&"</td>", "<td>"&index(index(ri!PRTRR_PipelineList, "daysTo", null()), ri!index, null())&"</td>", "<td>"&index(index(ri!PRTRR_PipelineList, "daysToNonCompliance", null()), ri!index, null())&"</td>", "</tr>" )
here we have 2 rule inputs:
ri!index -> Type -> Number(Integer)
ri!PRTRR_PipelineList -> Type -> CDT (Array) or Any Type
You can modify the property names inside this Child rule as per your cdt properties such as: ActivityType, LastProductionDate etc.. and also you can have any conditional pre-check if required as per your business requirement.
in my case: following is the input for the Parent rule, for demo:
{ { lineNumber: 123, uwi: "abc", activity: "test", lastprod: today(), nonComp: today()+1, daysTo: 2, daysToNonCompliance: 6 }, { lineNumber: 456, uwi: "def", activity: "test1", lastprod: today()+5, nonComp: today()+6, daysTo: 6, daysToNonCompliance: 17 } }
which you need to change with your data, at later point of time.
So at the end, when the parent rule executes, this generates your required response as shown below:
Hope this will help you in building Dynamic Email Body for your scenario.