So I've been able to make a second data source, pass down parameters, im all but ready, but I cant figure out how to send a collection of the field values in a column to the sub report. Ive tried setting a variable to the field value and sending that, I've tried sending the field directly.
I sort of assumed these wouldn't work because the data type is wrong, but i just don't know how to tell jasper that i want the fields as a collection.
I use this in JasperSoft Studio 5.6.0 and it work fine :
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{subReportDataField})]]></dataSourceExpression>
Where "subReportDataBean" is a field like this :
<field name="subReportDataBean" class="java.util.List">
<fieldDescription><![CDATA[subReportDataBean]]></fieldDescription>
</field>
Related
we are using azure devops hosted xml process.
i am trying to set Field A as required when Field B equals to Field C but the comparison do not work with i compare two reference fields.
if i compare a reference field to a specific value it works, but i need to compare 2 fields.
This is the comparison (G.CR and G.FixFor both equal 815)
<FIELD refname="G.BugReason">
<WHEN field="G.CR" value="G.FixFor">
<REQUIRED />
</WHEN>
</FIELD>
both of the fields are defined as strings.
it does work when i do the following comparison (when G.CR equals 815):
<FIELD refname="G.BugReason">
<WHEN field="G.CR" value="815">
<REQUIRED />
</WHEN>
</FIELD>
please help.
thanks.
Guy.
The scenario you ask about isn't supported.
You can define conditions that are based on what value is assigned to
a specific field or whether a user modifies a specific field.
According to our official doc -- Assign conditional-based values and rules. It's not able to directly compare two field as a conditional-based rules.
You could create a related user voice and vote up in our feature request page from Developer Community site. Our PM will kindly review your suggestion.
I have a report which receives a List parameter to use it in a IN clause:
$X{IN, personID, _personID}
The report works when running it through the web application or remote repository view in iReport.
Now I need to call it using the REST api. I have tried several different ways of passing the list value in my resource descriptor but none of them worked.
<resourceDescriptor name="Test_Report" wsType="reportUnit" uriString="/Test/Test_Report" isNew="false">
<parameter name="_personId" isListValue="true"><![CDATA[1]]></parameter>
</resourceDescriptor>
The above example returns the following error:
Invalid type java.lang.String for parameter _personId used in an IN clause; the value must be an array or a collection.
I have also try the following:
<parameter>
<name>_personId</name>
<value isListValue="true">
3
</value>
</parameter>
But this returns a report with all the records, not only the person with Id=3.
My workaround for this problem was to use the REST V2 services of JasperServer.
Added to this the V2 has two advantages over the first version of the service:
it doesn't require a resource descriptor
it runs and exports the report in a single GET request
All the information required to run and export the report is passed through the request URL, for example:
<host>/rest_v2/reports/Test/TestReport.html?_personId=3&_personId=4&_personId=5&_personId=6
Your approach is totally fine, but there is also another small tip with collection type arguments ( might be a bug)
If you have more than 1 item in the collection this is totally working correctly:
(3,4,5,6)->?_personId=3&_personId=4&_personId=5&_personId=6
If you have only 1 item in the collection you have to add empty one too:
(3)->?_personId=3&_personId=
By the way, I am using Jasper Server CE 7.2.0 on the docker.
I wanted to create a JasperReport which asks the user for a deliverer before it creates a report with data of the last the deliveries of the selected deliverer.
The problem, how I can do that? I found only examples where a parameter is created and the ArrayList is filled statically. But in my parameter I need the query result over the table of deliverers filled.
Can anybody tell me a possible solution?
I'm using Jaspersoft Server 5.1 which directly access a PostgreSQL database which has a datawarehouse structur. So it's not possible to use Java code.
Here is the documentation for adding input controls to reports in JasperReports Server:
http://community.jaspersoft.com/documentation/jasperreports-server-user-guide/adding-input-controls
Scroll down to the section that deals with query-based input controls. Your input control will have a name, such as deliverer. In your report, you must add deliverer as a parameter and reference it in your query, as you have done in your comment.
In reports I need to show localised field labels and entity names. For this I need to retrieve some pieces of metadata, namely -- localised entity names.
Can you access metadata in Fetch-based reports? If you can, how severely will performance suffer?
There is a hack to sort of get pick list values and default labels. Quoting from reference:
You must use the distinct clause, and create a seperate dataset to
fetch only the option set field like this.
<fetch version="1.0" output-format="xml-platform" mapping="logical"
distinct="true"> <entity name="account">
<attribute name="accountratingcode" /> </entity> </fetch>
This actually returns 2 columns to BIDS -
accountratingcode
accountratingcodevalue
Create a report parameter for the main report and in the Available
Values tab specify:
Get Values from a query
Dataset: Seperate Dataset with the Fetch XML
above
Value Field: accountratingcodeValue
Label Field:
accountratingcode
Sorry to say that entity metadata is not exposed via the FetchXml interface as neither "attributes" nor their corresponding "labels" are entities, so cannot be queried.
You can prove this by using the FetchXml builder ([details of getting it and making it work with CRM 2011 are here][1]). You will note that none of the available entities contain the information you seek.
Edit: looking at the core requirement (rather than answering the question in isolation as I originally did), it is possible to include "label" values in FetchXml statements, as #skfd notes in his own answer.
I have a report backed by a collection of MyJavaBean.
In this report I (of course) can get the properties of MyJavaBean declaring them in the Fields and using it on the details band, so far so good.
Now I want to be able to pass this MyJavaBean as a parameter of a subreport. Look that I want to be able to pass the javabean itself, not one of its propertys.
How can I make reference to one element of my collection in the detais band?
Referencing a bean
To declare a field that references the bean itself instead of one of its properties, set the field description to the keyword _THIS.
<field name="myJavaBean" class="com.your.package.MyJavaBean">
<fieldDescription>_THIS</fieldDescription>
</field>
You can then pass this as a subreport parameter like any other field.
<subreportParameter name="myJavaBean">
<subreportParameterExpression>
<![CDATA[$F{myJavaBean}]]>
</subreportParameterExpression>
</subreportParameter>
Methods in the bean can be called in the normal way, i.e: $F{myJavaBean}.someMethod()
Referencing a single element of the collection
Depending on what you are doing here it could be more difficult. If you want to only see the detail for the single element, set the printWhenExpression on the band to the key of the element you want. However, if you want to have some report elements reference one object in the collection while the rest of the band references another, it would probably be better for you to nest another subreport within the detail band.