Question

Passing a custom parameter from BPM Online to a Dev Express Report

Hello, I need to pass a parameter to a DevExpress report. I'm currently passing the selected values through the "filters" report parameter, but I need to pass additional info from BPM.

In the following screenshot (taken from https://community.bpmonline.com/system/files/bpmonline_crm_cg_7.2.pdf) It mentions that a page can be made and selected in Template Setup to manage the parameters of the report. The example mentioned here ("Base Report Parameters Page") is not available in the lookup.

Is a "Template Setup" page what i need to send custom parameters? In that case how would i set up this kind of page?

Thanks. 

Like

4 comments

Hello Matias,

To pass custom parameters to a DevExpress report additional development is required. Ryan explained how to do that in a community post (https://community.bpmonline.com/questions/pass-parameter-bpm-online-crm-edit-page-dev-express-report) and here is his explanation:

The way the report service works, it automatically passes the selected (or current) record(s) as esq filters. You can add a report parameter with the name of "Filters" and this will contain filters for the selected IDs. You just need to add the parameter to your report (it has to be named "Filters"). 

Then, in your report code, you can apply the filters like this in the BeforePrint event: 


 
var report = (Report)sender;
var userConnection = report.UserConnection;
 
var ds = report.CreateDataSet();
var filterTable = new DataTable();
filterTable.Columns.Add("Id");
 
// get filter Ids & load in table
var filters = report.Parameters["Filters"].Value as IEntitySchemaQueryFilterItem;
if (filters != null) 
{
	var filterEsq = new EntitySchemaQuery(userConnection.EntitySchemaManager, "UsrMyEntity");
	filterEsq.AddColumn("Id");
	filterEsq.Filters.Add(filters);
	filterTable.Load(userConnection, filterEsq);
}
 
// create report esq query
var query = new EntitySchemaQuery(userConnection.EntitySchemaManager, "UsrMyEntity");
// dynamically add columns selected for report 
foreach (DataColumn column in ds.Tables["UsrMyEntity"].Columns) 
{
	query.AddColumn(column.ColumnName);
}
 
// apply selected Id filters
if (filterTable.Rows.Count > 0) 
{
	var idFilters = new EntitySchemaQueryFilterCollection(query) {
		LogicalOperation = LogicalOperationStrict.Or
	};
	foreach (DataRow row in filterTable.Rows) 
	{
		if (row["Id"] != null) 
		{
			idFilters.Add(query.CreateFilterWithParameters(FilterComparisonType.Equal, "Id", row["Id"]));
		}
	}
	query.Filters.Add(idFilters);
}
 
// set as datasource for report 
ds.Tables["UsrMyEntity"].Load(userConnection, query);
report.DataSource = ds;

This method will work whether you've selected a row or rows in the section list, as well as the current ID of the edit page you're on. From there, to get additional values from the record you could perform additional queries.

Best regards,

Oscar

Hello Oscar, thanks for the help.
I'm currently passing the selected rows Id to the "filters" parameters and using them on the report. What i need Is the user to be able to pass certain parameters to the report. This info can't be retrieved with additional queries as it needs to be an input from the user at the moment of printing.
In the image I added in the question it mentions the possibility to select a page to manage the parameters in the "Template Setup"  lookup in the DevExpress Printable Registration Card. Is this what I need to pass a certain parameter at the moment of running the DevExpress printable?

Oscar Dylan,

Hi Oscar!  

What we need is to make a report that has a page of parameters such as 
the "Activity Report" report. 
I was checking and found that the parameter page is stored in the SysOptionsPageSchemaUId 
field but it works only for reports that are of the "type" analytics report stored in SysModuleAnalyticsReport. 
I was able to build a module and change for example the page shown in the activity report, 
as well as register a report as an analytic with a custom page but the latter does not work. 
How could we do to send certain parameters as a filter to our report?

Thank you!

Regards

Dear Uriel,
Unfortunately, there is no example for the requesting information. Please check the code above for the additional information. In addition, please consider to use Ms Word instead DevExpress Report. 
Best regards,
Norton

Log in or register to comment