Hi there,
Is there anyway to ensure the order in which parameters are evaluated? I have 2 parameters (e.g.) and 1 refers to the other and is a substring of that first parameter. Sometimes though, param2 is null, sometimes it has a value taken from Param1. Just wondering how I can enforce P1 is always evaluated before P2?
You can run the below source with Parameter1 being test1,test2,test3 repeatedly to see what I mean. Sometimes Parameter2 will be null, sometimes it will be "test1".
Sample source:
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="sample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d9385bae-2cc3-433e-bf49-27d6a50e3d62">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="Parameter1" class="java.lang.String"/>
<parameter name="Parameter2" class="java.lang.String">
<defaultValueExpression><![CDATA[$P{Parameter1}.indexOf(",") > 0?$P{Parameter1}.substring(0, $P{Parameter1}.indexOf(",")):$P{Parameter1}]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="120" y="10" width="278" height="30" uuid="924e8f84-e48b-4975-af13-c90b4b5973cf"/>
<textFieldExpression><![CDATA["param1: " + $P{Parameter1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="50" width="277" height="30" uuid="f3d8943b-253f-4a90-8810-26802bb463d2"/>
<textFieldExpression><![CDATA["param2: " + $P{Parameter2}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
2 Answers:
Update... found the solution. I had my "2nd" parameter setup as for prompting. Once i removed that flag it processed the for prompting first... then it processed the not for prompting parameter and it resolved my issue. I am still unclear on any sequence/order that exists when evaluating parameters (and variables) but at least a "for prompting" param gets evaluated before any that are not for prompting.