Thursday, March 1, 2012

Query information in a report header

Today I had a case where I needed the user entered report query shown in the header like this (BTW: It's Norwegian language i the query dialog/report, but you will figure out what I mean):




All you need is to create the "showHeader" method shown below and use it in the pageheader or wherever you need to see this information.

The Code:
display formLetterTxt showHeader()
{
   int i,j,CurFieldID;
   formLetterTxt headerInfo;
   str CurPName;

   for (i=1;i<=element.query().dataSourceCount();i++)
   {
      for (j=1;j<=element.query().dataSourceNo(i).rangeCount();j++)
      {
         CurFieldID=fieldname2ID(element.query().dataSourceno(i).table(),element.query().dataSourceNo(i).range(j).name());
         CurPName=FieldID2pName(element.query().dataSourceno(i).table(),curFieldID);
         headerinfo+=(headerinfo ? '\n' : '')+curPName+':'+ element.query().dataSourceNo(i).range(j).value();
      }
   }

   return strfmt("Rapportparametere benyttet:\n%1",headerinfo);
//Translates to:   return strfmt("Rapportparams used:\n%1",headerinfo);
}

No comments:

Post a Comment