I am trying to add a simple subreport to a report in Reporting Services using Dynamics CRM (FetchXML). This is all on my local machine, neither report has been published yet. I am only trying to get them to run in Reporting Services. I added a Parameter to the subreport for the field "name". I then added a subreport to the main report. I then selected the subreport via subreport properties and passed the parameter here as well.
Here is the FetchXML from the Main Report
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="name" />
<attribute name="ownerid" />
<attribute name="new_databaseserver" />
<attribute name="new_databasename" />
<attribute name="accountid" />
<order attribute="name" descending="false" />
</entity>
</fetch>
Here is the FetchXML from the subreport
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="name" />
<attribute name="accountid" />
<attribute name="new_adam" />
<order attribute="name" descending="false" />
</entity>
</fetch>
Here is the error:
[rsErrorExecutingSubreport] An error occurred while executing the subreport 'SubReport1' (Instance: 19iT0R0x0S0): Data retrieval failed for the subreport, 'SubReport1', located at: /SubReport1. Please check the log files for more information.
I've been racking my brain over this all weekend. Any help would be really appreciated.
I noticed you don't have the filter expression in subreport. I think reporting services tries to get all accounts data from CRM two times: for 1st report and then for subreport. Try use this fetch for subreport:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="name" />
<attribute name="accountid" />
<attribute name="new_adam" />
<order attribute="name" descending="false" />
<filter type="and">
<condition attribute="name" operator="eq" value="#Name" />
</filter>
</entity>
</fetch>
The #Name is name of your parameter.
Related
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.
In FetchXml Query I have end date being passed as parameter but for Start Date the parameter is based on user selection. For example, a user can select as MTD, QTD and YTD as reporting time. So if user select QTD as start date and End Date is select some date in February like 25th. So I need to pull records that were created from Start of the quarter to the selected date in end date.
What I can do I make parameter but its values are fixed in a sense what if the user is interested to select date form last year.
The way around is to use textbox and get sorted the start date based and selected value and pass this new expression as parameter to dataset.
These are just assumption, I would like to hear form gurus to get this query sorted out.
Below is my FetchXml query:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="account" >
<attribute name="name" />
<attribute name="address1_telephone1" />
<attribute name="fax" />
<attribute name="accountid" />
<order attribute="fullname" descending="false" />
<filter type="and" >
<condition attribute="createdon" operator="on-or-after" value="" />
<condition attribute="createdon" operator="on-or-before" value="" />
</filter>
</entity>
</fetch>
You can use specific FetchXML Operators for each of your query types:
MTD: this-month
QTD: this-fiscal-period
YTD: this-year
For example:
<filter type="and" >
<condition attribute="createdon" operator="this-month" />
</filter>
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.
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>
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.