AnsweredAssumed Answered

Creating a list based on parameters and date

Question asked by Michael McGowan on Jul 26, 2019
Latest reply on Jul 29, 2019 by Michael McGowan

On our site there are activities that members take to earn points and then they can use those points to enter drawings.

I would like to send a monthly email based on the following.

  1. List the activities where the status equals “Completed”.
  2. Only show the activities that were completed this month based on the column updatedAt and list them (if there is more than one) in descending order based on the date.
  3. Show the name of the completed activity and the points earned.
  4. Add up the points earned this month and show the total number of points earned.

 Trying to break this project down, I am first trying to get the list of activities a person has completed. However, I am finding that it not only gives me the information in the entire row, it ignores the “Completed” status and gives me activities a person had started as well as completed.

Here’s the code

 

#if (${sPAdActivity_cList.get(0).activityStatus} == "Completed" )
#set( $activityDescription = ${sPAdActivity_cList.get(0).description})
#else
#end

#set( $pointsEarned = ${sPAdActivity_cList.get(0).points})
#set( $myIndicator = "1")

<table width="600" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #000">
<tr>
<td bgcolor="#005daa" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; padding-left:5px; padding-right:5px; color:#fff; padding-top:5px; padding-bottom:5px;"><strong>Activity</strong></td>
<td bgcolor="#005daa" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; padding-left:5px; padding-right:5px; color:#FFF; padding-top:5px; padding-bottom:5px;"><strong>Points Earned</strong></td>
</tr>
#foreach( $activityDescription in $sorter.sort($sPAdActivity_cList,["updatedAt:desc"]))
#if ($myIndicator == "1") ##This alternates row color if there is more than one row
#set( $rowColor = "#ffffff")
#set( $myIndicator = "0")
#else
#set( $rowColor = "#e6eff8")
#set( $myIndicator = "1")
#end
<tr>
<td bgcolor="$rowColor" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; padding-left:5px; padding-right:5px; color:#000; padding-top:5px; padding-bottom:5px;">$activityDescription</td>
<td bgcolor="$rowColor" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; padding-left:5px; padding-right:5px; color:#000; padding-top:5px; padding-bottom:5px;">$pointsEarned</td>
</tr>
#end
<tr>
<td bgcolor="#005daa" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px; color:#fff;"><strong>Total Points Earned</strong></td>
<td bgcolor="#005daa" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; padding-left:5px; padding-right:5px; color:#fff; padding-top:5px; padding-bottom:5px;"><strong>$totalPoints</strong></td>
</tr>
</table>

Here is what it returns for one person I know has completed only a few offers but started a few more.

Been at this for a few weeks and not getting anywhere. Any help would be appreciated.

Outcomes