Just updating for posterity.
My issue was that I needed to load the cases using forcase or loadcase before calling setreportdata(). Therefore I used the following code to loop through the cases and load the ones for the ED that I wanted. It loads the data for each case into an array and then that array is used to display the data in the report.
Code: Select all
string array reportarray(50,10);
function enumerationRpt()
recode ME_ED => parish; //recode ed to parish
1-181 => 201; //St. Michael
182-295 => 202; //Christ Church
196-335 => 203; //St. George
336-397 => 204; //St. Philip
398-418 => 205; //St. John
419-479 => 206; //St. James
480-508 => 207; //St. Thomas
509-521 => 208; //St. Joseph
522-532 => 209; //St. Andrew
533-559 => 210; //St. Peter
560-583 => 211; //St. Lucy
endrecode;
numeric i = 1;
forcase ENUMERATIONREPORT_DICT where ERED_NO = ME_ED do //for each case in enumeration report in the current ED
reportarray(i,1) = getlabel(ERFIELD_OFFICER_VS1,ERFIELD_OFFICER); //field officer
reportarray(i,2) = maketext("%d",ERUNIT_NO);
reportarray(i,3) = maketext("%d",ERSERIAL_NO);
reportarray(i,4) = maketext("%d/%d/%d",ERWEEKYEAR,ERWEEKMONTH,ERWEEKDAY); //week ending
reportarray(i,5) = ERLAST_NAME;
reportarray(i,6) = ERFIRST_NAME;
reportarray(i,7) = ERADDRESS;
reportarray(i,8) = maketext("%d/%d/%d",ERSTARTY,ERSTARTM,ERSTARTD);
reportarray(i,9) = maketext("%d/%d/%d",ERSTARTY,ERSTARTM,ERSTARTD);
reportarray(i,10) = ERREMARKS;
inc(i);
endfor;
setreportdata("PARRPT",maketext("%d",parish));
setreportdata("EDRPT", maketext("%d",ME_ED));
setreportdata(reportarray);
report("../Reports/enumeratorrpt.html");
end;
The report template was changed to read the data from an array instead:
Code: Select all
<div id="cspro_report"></div>
<script type="application/vnd.cspro.report-template" id="cspro_report_template">
<h2>Continuous Labour Force Sample Survey Field Officer Enumeration Report<h2>
<h3>ED No: {{EDRPT}}</h3>
<h3>Parish: {{PARRPT}}</h3>
<table border="1">
<tr><th>Name of field officer</th><th>Unit No</th><th>Serial No</th><th>Week ending</th><th>Head of Household Last name</th><th>Head of Household First Name</th><th>Address of Head of Household</th><th>Date Started</th><th>Date Completed</th><th>Remarks</th></tr>
{{#REPORTARRAY}}
<tr> {{#.}}<td>{{.}}</td>{{/.}}</tr>
{{/REPORTARRAY}}
</table>
</script>
So it works now. Thanks to the team for all your help!