I have a form which has two pages. Each page has 2 textfields.
I'm trying to group the values of a result by page with the code below.
The pages variable contains records, which contains a pagefields cell, which in return is an array of all the answers beloning to the field contained within the page.
However, when running the code below, all the pages contain all of the values of the result.
I'm i going about this the wrong way or is there an easier way to accomplish this?
OBJECT formobj := OpenWHFSObject(formid);
OBJECT formresults := OpenFormFileResults(formobj);
this->pdfdata := formresults->GetSingleResult(resultguid);
RECORD singleresult := this->pdfdata;
OBJECT formdef := OpenFormFileDefinition(formobj);
RECORD ARRAY wittyresults := formresults->GetWittyResultData(singleresult).allfields;
RECORD ARRAY pages;
FOR (INTEGER idx := 0; idx < formdef->GetNumPages(); idx := idx + 1)
{
OBJECT page := formdef->GetPage(idx);
RECORD ARRAY pagefields;
FOREVERY (RECORD result FROM wittyresults)
{
OBJECT component := page->LookupComponent(result.fieldguid);
IF (ObjectExists(component))
{
INSERT result INTO pagefields AT END;
}
}
INSERT cell [pagefields] INTO pages AT END;
}