ian.waterman Posted March 29, 2018 Share Posted March 29, 2018 Building a report which lists out invoices within an agreement. The headers for the invoice details are in the Agreement Header.Generally works fine however, if list of invoices goes over to next page I want the Agreement header to repeat. I have tried checking the Reprint Header on new page , but that causes header to reprint irrespective whether invoice list flows onto next page.I created a Count of Agreements which Increments and resets on the Agreement Group and a record count. According to this entry https://community.jaspersoft.com/wiki/variables the agrement count should only evaluate on change of Agreement. However, it seems to count every record.I had hoped that I could use a print when expression that only allows the Agreement Header to print when the two counts are equal and <> 1, (in most cases invoice list is more than 1 but had this just incase)However, as the two counts are always equal the header always prints. What am I doing wrong with the Count Variables Is there a better way to conditionally control the subsequent printing of the agreement headerSource Description of Vars</variable> <variable name="PHControl" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber" incrementType="Group" incrementGroup="AgreementNumber"> <variableExpression><![CDATA[$V{PHControl}+1]]></variableExpression> <initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression> </variable> <variable name="RecNo" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber"> <variableExpression><![CDATA[$V{RecNo}+1]]></variableExpression> <initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression> </variable>Thank youIan Link to comment Share on other sites More sharing options...
kevin.weinhold Posted March 29, 2018 Share Posted March 29, 2018 You need an increment type defined for RecNo, which would be "Page". Also, I don't think you need PHControl.On the first page, RecNo is set to zero. On the second page it is set to 1, and on the third it is 2...etc. When group resets, it becomes zero again (first page for new group).However, if you are tying to do something else, please clarify your question. Link to comment Share on other sites More sharing options...
ian.waterman Posted April 3, 2018 Author Share Posted April 3, 2018 KevinThank you for guidance,Still not working as expectedI have changed Vars as suggested</variable><variable name="RecNo" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber" incrementType="Page"><variableExpression><![CDATA[$V{RecNo}+1]]></variableExpression><initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression></variable><variable name="PHControl" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber"><variableExpression><![CDATA[$V{RecNo}]]></variableExpression><initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression></variable>Print when on Header is set as </group><group name="AgreementNumber" isReprintHeaderOnEachPage="true" keepTogether="true"><groupExpression><![CDATA[$F{AgreementNumber}]]></groupExpression><groupHeader><band height="149"><printWhenExpression><![CDATA[$V{RecNo}.doubleValue()!=$V{PHControl}.doubleValue()]]></printWhenExpression><textField isStretchWithOverflow="true" evaluationTime="Group" evaluationGroup="AgreementNumber" pattern="" isBlankWhenNull="false">I have placed VARs on report on Page in both Group Header and Footer. In Header PHControl = 2 and Recno = 1In Footer They are both 2 on pg1 however, group header still prints on Page 2Cant see how Values are being set?Any suggestions?Ian Link to comment Share on other sites More sharing options...
ian.waterman Posted April 3, 2018 Author Share Posted April 3, 2018 Sorry error in above In Header REcNo = 0When header is printed on page 2 both are still showing as 2, and this ignore the Print when expression$V{RecNo}.doubleValue()!=$V{PHControl}.doubleValue() Link to comment Share on other sites More sharing options...
ian.waterman Posted April 3, 2018 Author Share Posted April 3, 2018 The answer which was emailed is different to response below. Don't think solution below will work as I only want to print Agreement Header on new page if invoice details overflow to page 2. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now