Hi,
As far as I know, pre-filtering won't work on custom views/database.
You can pass SSRS parameters to filter the data in your report.
For example, if you need to dhow data related to current record, you can try following steps:
- Create hidden parameter in SSRS report, e.g. @AccountID (String).
- Add a ribbon button to run the report, call a JavaScript action (button command) and pass primaryControl parameter.
- Get the data to be passed to report, here is the code to launch the report.
var report_account_en = JSON.parse('{"reportId":"{report-guid}", "reportName":"Account Sample Report"}');
// OnClick: on the ribbon button
function report_clicked(primaryControl) {
var formContext = primaryControl.getFormContext();
var accountNo = formContext.getAttribute("accountnumber").getValue();
if (accountNo == null || accountNo == "") {
alert("Cannot get Account Number.");
} else {
// Please notep, @AccountId after p: is the SSRS parameter name.
openReport(primaryControl, report_account_en.reportId, report_account_en.reportName, "p:@AccoountID=" accountNo);
}
}
// Utility Function to open report window
function openReport (primaryControl, reportId, reportName, params) {
var formContext = primaryControl;
var globalContext = Xrm.Utility.getGlobalContext();
var urlOptions = { height: 800, width: 800 };
var entityType = encodeURIComponent("1");
var entityId = encodeURIComponent(formContext.data.entity.getId());
var reportGuid = encodeURIComponent(reportId); // Include curly brackets
var reportName = encodeURIComponent(reportName);
//var parameters = encodeURIComponent(params);
var serverUrl = globalContext.getClientUrl();
var reportUrl = serverUrl "/crmreports/viewer/viewer.aspx?action=run&context=records&helpID="
reportName "&id=" reportGuid "&records="
"" entityId "&recordstype=" entityType
"&" params;
Xrm.Navigation.openUrl(reportUrl, urlOptions);
}
This is just an example, you can pass multiple parameters as well.
Please note, you have to upload the report in the Dynamics 365 and use it's GUID to launch the report.
Look into following blog for more details:
https://community.dynamics.com/365/b/dynamics365enterprisecloudfronts/posts/open-report-from-custom-ribbon-button-on-entity-form