Tips on using the publishreports executable

Update: see the bottom for a solution to be able to use the filter in the report!

Some days ago I posted an article around how to move reports from a server to another server in the development process. Now I've been working with it, I can share some tips.

The first tip is on how to publish the reports. How does the publishreports.exe know where to find the publish.config and the reports? This wasn't completely clear to me on this page. It appears that you will need to go to the folder that you have created in the first step by using downloadreports.exe. Then you can do two things. Either call the publishreports executable on the server, by default on the location "C:\Program Files\Microsoft CRM\Reports\PublishReports.exe" or you can copy the file publishreports.exe and the file "Microsoft.CRM.Tools.Logging.dll" to the same folder and run publishreports from there. This will allow you to create an installer application because you know for sure that the publishreports executable is in your folder. You cannot be sure that the executable is in the c:\program files folder because thats a choice of the person installing CRM.

Furthermore you will notice that the publishreports will throw this error on your reports:


This error is caused due to the filter that is set in your report (by default set to last modified within the last 30 days). Each report has a layout like this:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="CRMDEV30_MSCRM">
<ConnectionProperties>
<IntegratedSecurity></IntegratedSecurity>
<ConnectString></ConnectString>
<DataProvider></DataProvider>
</ConnectionProperties>
<rd:DataSourceID></rd:DataSourceID>
</DataSource>
</DataSources>
<PageWidth></PageWidth>
<rd:DrawGrid></rd:DrawGrid>
<InteractiveWidth></InteractiveWidth>
<rd:GridSpacing></rd:GridSpacing>
<rd:SnapToGrid></rd:SnapToGrid>
<Body>
</Body>
<rd:ReportID></rd:ReportID>
<DataSets>
<DataSet Name="CRMDEV30_MSCRM">
<Query>
<rd:UseGenericDesigner></rd:UseGenericDesigner>
<CommandText></CommandText>
<DataSourceName></DataSourceName>
</Query>
<Fields>
</Fields>
</DataSet>
</DataSets>
<Code>
</Code>
<Width></Width>
<InteractiveHeight></InteractiveHeight>
<Language></Language>
<PageHeight></PageHeight>
</Report>

In your report you will find one more node between the pageheight and the end of the report:
<Custom>
<MSCRM xmlns="mscrm"><ReportFilter><ReportEntity paramname="P1" displayname="Contacts"><fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="contact"><all-attributes /><filter type="and"><condition attribute="modifiedon" operator="last-x-days" value="30"/></filter></entity></fetch></ReportEntity></ReportFilter></MSCRM> </Custom>

Remove this line from your report and you will be able to import the report. Keep in mind that you will have to set the default filter for your report afterwards!

Update:
One of my colleagues, Philipp Uihlein, has sent me an email regarding this blog post. He has found a way to keep the default filter in the definition! See his text for the details:

Hi Ronald,

I found out that the tool can handle the <Custom> tag when you add a namespace to the xml.

In the Account Summary.rdl for example I replaced the
<Custom> <MSCRM xmlns="mscrm">&lt;ReportFilter&gt;&lt;ReportEntity paramname="CRM_FilteredAccount"&gt;&lt;fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"&gt;&lt;entity name="account"&gt;&lt;all-attributes /&gt;&lt;filter type="and"&gt;&lt;condition attribute="modifiedon" operator="last-x-days" value="30" /&gt;&lt;/filter&gt;&lt;/entity&gt;&lt;/fetch&gt;&lt;/ReportEntity&gt;&lt;/ReportFilter&gt;</MSCRM> </Custom>


node with

<Custom xmlns="http://schemas.microsoft.com/crm/2006/WebServices" xmlns:mscrm="http://schemas.microsoft.com/crm/2006/WebServices"> <MSCRM xmlns="mscrm">&lt;ReportFilter&gt;&lt;ReportEntity paramname="CRM_FilteredAccount"&gt;&lt;fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"&gt;&lt;entity name="account"&gt;&lt;all-attributes /&gt;&lt;filter type="and"&gt;&lt;condition attribute="modifiedon" operator="last-x-days" value="30" /&gt;&lt;/filter&gt;&lt;/entity&gt;&lt;/fetch&gt;&lt;/ReportEntity&gt;&lt;/ReportFilter&gt;</MSCRM> </Custom>


and could publish the report using PublishReports.exe without problems.

Best regards,

Philipp

1 comment:

Anonymous said...

I can deploy all my reports to the new server, but I'n not be able to copy the default filters for each report. When I open the uploaded reports on the target server, my default filter are missed and crm show me the default one.
How can i solve this problem?