Allow a select all option in Dynamic CRM report - reporting-services

Let's say I have a very simple SSRS report for Dynamic365 Online as following:
The FetchXML query is as following:
<fetch distinct="false" no-lock="false" mapping="logical">
<entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccount">
<attribute name="name" alias="name" />
<attribute name="createdon" alias="createdon" />
<attribute name="ownerid" />
</entity>
Now I want to filter account by owner, I add a parameter as following:
The value for my filter is retrieved from CRM with the following FetchXML query and will be displayed as a drop down list:
<fetch distinct="false" no-lock="false" mapping="logical">
<entity name="systemuser">
<attribute name="systemuserid" />
<attribute name="fullname" />
<order attribute="fullname" />
</entity>
My intention is user can select an owner, and the report will only display accounts belong to that user, but if they don't select anything then all accounts will be displayed. However, if the drop down list is empty, I get the following error while trying to execute my report:
From what I have found on various websites, "Allow blank value" and "Allow null value" will only work if there already is a blank/null value from the result of my second query. If my filter list were built using SQL query, that would not be a problem since I can simply insert a dummy null value, but I can't find a way to do the same with FetchXML query.
So my question is how can I add a dummy/null value to my filter list in this case?
Note: I have added how I worked around this problem in an answer below, but I feel that must be a better way to solve what I think is a common problem.

I added a new dummy user as following,
notice that I set the display name for this user as "(Please Select)":
Then in my report, I set the default value for my filter as this dummy user, the result is I now have a "select all" option that looks quite well.

Related

SSRS - The report parameter has a defaultValue or a ValidValue that depends on the report parameter

In an SSRS report, I have a fetchXML query that is dependent on the parameters that the users will choose from the UI that are defined in the report:
<fetch xmlns:generator="MarkMpn.SQL4CDS">
<entity name="new_r10logentries">
<attribute name="new_quarter" />
<attribute name="new_cr884_company" />
<link-entity name="cr884_company" to="new_cr884_company" from="cr884_companyid" alias="cr884_company" link-type="inner">
<attribute name="cr884_company" />
<attribute name="cr884_companyid" />
<filter>
<condition attribute="cr884_company" operator="eq" value="#CompanyParam">
<value />
</condition>
</filter>
</link-entity>
<filter>
<condition attribute="new_quarter" operator="eq" value="#QuarterParam" />
</filter>
</entity>
</fetch>
The parameters settings that I have are the below:
The companyParam is based on the dataset of the fetchXML and will populate the list of the companies' names.
The quarterParam is a list of options that are not based on the dataset.
When trying to publish/preview the report I got the below error:
Knowing I am passing the param as per the above query and the company column name that I am querying against is of type text and not GUID:
I hardcoded the company name in the query it works perfectly and in the parameters, it populates the list of the companies in the UI. However, when I pass the param in the fetchXML nothing happens as the CompanyName in the UI display null values.
Could you please support solving this issue? I have spent 3 hours changing in query with no result.
Resources that I look for support:
Input parameter SSRS
Community Dynamics
Any help is greatly appreciated.
Thank you!
your CompanyParam is list of companies which you retrieve from Dataset1 (from screenshot--> get values from query).
You pass this list(companies) selected one comapny by user to same dataset1 to retrieve your result and this is your circular reference.
Create a new Dataset "DatasetRetrieveCompanies" This dataset will give you all companies based on your fetchxml. Then add this dataset to your CompanyParam (get values from query). This should most probably solve your issue
I have almost zero experience with FetchXML so this is just an educated guess...
I would have expected you to have 2 datasets defined in your report.
Gets a list of companies based on QuarterParam
Gets the data for the report output based on CompanyParam
But it appears that you only have 1.
If I understand the XML you posted correctly, it looks like you have a parameter called 'CompanyParam' that uses a dataset that has a filter, the filter uses 'CompanyParam' - which is not possible, its a circular reference.

How do I link the same entity in FetchXml (ssrs) with a different prefilterparametername?

I'm building a SSRS report for Dynamics CRM so I have to use FetchXml. For example I have 10 accounts and I have to substract 5 accounts form a second query.
I prepared 2 fetchxml reporting parameters:
CRM_FilteredAccount for the 10 accounts
CRM_FilteredAccountNeg for the accounts I have to substract
And I have the Dataset shown below.
Dataset so far:
<fetch distinct="false" useraworderby="false" no-lock="false" mapping="logical" >
<entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccount" >
<attribute name="name" alias="name" />
</entity>
</fetch>
(Not working) Dataset with link-entity with different parameter:
<fetch distinct="false" useraworderby="false" no-lock="false" mapping="logical" >
<entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccount" >
<attribute name="name" alias="name" />
<link-entity name="account" enableprefiltering="1" prefilterparametername="CRM_FilteredAccountNeg" from="accountid" to="accountid" link-type="outer" alias="neg" >
<filter>
<condition entityname="neg" attribute="accountid" operator="null" />
</filter>
</link-entity>
</entity>
</fetch>
I expected the first filterparametet to give a result of 10 accounts.
Then with the link-entity with the second filterparameter to give a result of only 5 accounts remaining.
Alright let’s do something like below:
1st dataset lets call it “Negative “
For this dataset use fetchxml retrieving account where account id is not null.
This dataset will get us 5 records.
Now for this dataset we will have accountid field use this field as Parameter and call is “NegativeAccounID” ie it will contain Guid of all account which have to be excluded from our Next fetchxml
Now 2nd dataset, lets call it “Result”
For this dataset use fetchxml retrieving all account where accountid not eq NegativeAccountId (parameter) we defined.
This will give you exact result.
You will have to undesirable how parameter works.

SSRS report - Display 1 to Many relationships

I am trying to build a custom SSRS report and publish to our CRM system. I have a Dataset created using FetchXml by connecting to Microsoft Dynamics CRM 365. The data set has 1 to Many and Many to Many relationships. The query looks fine and I am able to preview the Dataset results in Visual Studio. I am able to display the primary entity fields in the report but failed to show the 1 to Many relationship values. Please suggest on how to get this wprking. My fetch xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="entity1">
<attribute name="name"/>
<link-entity name="entity2" from="entity2id" to="entity1id">
<attribute name="name"/>
</link-entity>
</entity>
</fetch>
alias & link-type is missing in your query syntax.
<link-entity name="entity2" from="entity2id" to="entity1id" alias="xyz" link-type="inner" >
On a side note, I recommend you to use Xrmtoolbox FetchXML builder to build the query without errors.

How to get the data from the Fetch XML on the basis of Month in SSRS Report?

I have to fetch the data using FETCH XML where parameter will be year and the field in my CRM is date time field. So is there any way to fetch the data according to month.
For Example : Launch Date : 12/02/2016
Parameter for Report : 2016
Then I have to get the count according to month so as per example February count will be 1.
I have attached the Image for more understanding.
It's not possible, as far as I know, to filter a query using only the year so a possible workaround is to create a start date (01/01/YYYY) and a end date (31/12/YYYY) and use the "On or after" and "On or before" operators. In order to get the count per month, you can use the dategrouping paramenter.
The following is an example (contacts created by month in 2016):
<fetch aggregate="true" >
<entity name="contact" >
<attribute name="createdon" alias="month" groupby="true" dategrouping="month" />
<attribute name="contactid" alias="count" aggregate="count" />
<filter>
<condition attribute="createdon" operator="on-or-after" value="01/01/2016" />
<condition attribute="createdon" operator="on-or-before" value="12/31/2016" />
</filter>
</entity>
</fetch>

How to preselect a multiselect parameter using prefiltering in SSRS with fetchxml in Dynamics CRM 2016

I have an SSRS report query for which is in fetchxml. The main dataset "DS_PromissoryNotes" which fetches data for the report has a pretty basic query.
<?xml version="1.0" encoding=""?>
<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0" >
<entity name="promissorynote">
<attribute name="promissorynoteid" />
<attribute name="totalamount" />
<attribute name="name" />
<attribute name="duedate" />
<attribute name="pn_customer" />
<attribute name="pn_distributor" />
<attribute name="dateofissue" />
<order descending="false" attribute="name" />
<filter type="and" >
<condition attribute="promissorynoteid" value="#PromissoryNoteId" operator="in" />
</filter>
</entity>
</fetch>
As you can note that the fetchXML query takes a parameter #PromissoryNoteId which can be multiple so I have "Allow multiple" checked of course. Data for the parameter is fetched from another dataset "DS_PNID" which is almost similar to the above fetchXML query only fetching 'name' and 'promissorynoteid' attribute with no filter condition.
I want to be able to select multiple records from the Promissory Notes grid displayed on the entity's page and run report for the selected record. It should display the report data and also mark the selected PromissoryNoteIds in the multi-select dropdown filter so that I can modify the selection and view updated report from the report page itself.
I tried applying prefiltering on the main dataset "DS_PromissoryNotes" like this
<entity name="core_promissorynote" enableprefiltering="true" prefilterparametername="CRM_promissorynoteid">
After doing this I added it as new report. When I ran the report it gives me same result i.e. I have to manually select the PromissoryIDs from the filter dropdown. Promissory ID belonging to those records are not preselected.
P.S. When I remove the parameter and only use prefilter, it works fine. But I want to have that dropdown as the report is also present in report area where the report is run without selecting the records and the dropdown is the only way for selecting the PromissoryIds. I also don't want to make 2 separate reports.
Please help.
OK so I figured it out the next day. Didn't have time to post so posting it now.
What I basically did is,
Removed prefiltering from the main dataset. Also deleted the parameter
which was created due to prefiltering.
Created another dataset "DS_PrefilteredPNID" which is same as
"DS_PNID" (dataset which fetches Promissory Note IDs for my
parameter) and applied prefiltering on the newly created dataset.
Make sure that the newly created parameter is placed above the old one in
sequence.
Now, edit the old parameter. In the default section, choose "from
query". Then select the newly created dataset and value.
BOOM! This works flawlessly.