0
votes

Subreport:

<variable name="rota" class="java.lang.String" resetType="None">
    <variableExpression><![CDATA["ola"]]></variableExpression>
    <initialValueExpression><![CDATA["ola"]]></initialValueExpression>
</variable>

Main Report:

<variable name="rota" class="java.lang.String" resetType="None"/>
<title>
    <band height="41">
        <textField isBlankWhenNull="false">
            <reportElement x="0" y="6" width="100" height="30" uuid="e7e71af8-3694-4255-9b94-0587f377f7d4"/>
            <textElement markup="html">
                <font size="18"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{rota}]]></textFieldExpression>
        </textField>
    </band>
</title>
<detail>
    <band height="282">
        <printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
        <subreport>
            <reportElement x="-10" y="0" width="560" height="200" isPrintInFirstWholeBand="true" uuid="4bd58f02-975c-430f-87ad-41a55bd422ea">
                <printWhenExpression><![CDATA[$V{PAGE_COUNT} == 1]]></printWhenExpression>
            </reportElement>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <returnValue subreportVariable="rota" toVariable="rota"/>
            <subreportExpression><![CDATA["C:/Users/Pedro Fernandes/JaspersoftWorkspace/MyReports/ticketspartidasubreport.jasper"]]></subreportExpression>
        </subreport>
    </band>
</detail>

The variable $F{rota} is always NULL on main report. I know that this topic was already posted, but none of the solutions were working for me. Can someone help me? thks!

2

2 Answers

0
votes

Your issue seems to be that the subreport occurs on a band beneath the printed variable $V{rota}. The variable won't be retrieved until the subreport has returned the value, so you will have to print/use the variable on some band after the subreport element. Try switching the order of the bands. Hope this helps

0
votes

The problem is that the variables tha i want to use in the end must have calculation type SYSTEM. Doing that, the problem is resolved.