Ticket T169414
Visible to All Users

How execute "copy pre-defined reports" in XAF ReportsV2 from code?

created 10 years ago

Hi,

We have created several "templates" for the standard reports in our application.  How do we "automate" the process of copying the pre-defined reports from the code? And while creating a "copy", how do we change its name?

For example, let say we have "Sales Report Template".   When it is "copied" we want its name to be "Sales Report" .

Answers approved by DevExpress Support

created 10 years ago

Hello Voxdei,

You can create a copy of the existing report using the ReportDataProvider.ReportsStorage.CopyFrom method. Here is an example:

C#
Type reportDataType = Application.Modules.FindModule<ReportsModuleV2>().ReportDataType; using (IObjectSpace os = ReportDataProvider.ReportObjectSpaceProvider.CreateObjectSpace(reportDataType)) { IReportDataV2 template = (IReportDataV2)os.FindObject(reportDataType, new BinaryOperator("DisplayName", "Sales Report Template")); IReportDataV2Writable reportData = (IReportDataV2Writable)os.CreateObject(reportDataType); ReportDataProvider.ReportsStorage.CopyFrom(template, reportData); reportData.SetDisplayName("Sales Report"); os.CommitChanges(); }

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.