How to save report file to use workorder number instead of xtraReport1

By default, if you save a report template to a file (PDF, XLS, CSV, etc), the file name will default to xtraReport1 (as in xtraReport1.pdf or xtraReport1.csv, etc).

The following is an example of how to include a script in an AyaNova 7 report template so that the file name is taken from the workorder number.
And this example will also include how to suffix preset text as well (i…e report file name saved in PDF format for a workorder # 56 would be 56_SR.PDF)

[ul]
[li]Download the sample report template http://www.ayanova.com/Downloads/ReportTemplates/FILENAMEISWONUMBERSampleDispatchingReport.zip
[/li][li]Extract and import as per http://www.ayanova.com/AyaNova7webHelp/importing_a_report_template.htm
[/li][li]Move to your Service Workorders grid, open a specific workorder entry screen, open the report template WO NUMBER Sample Dispatching Report
[/li][li]Preview in the report template designer
[/li][li]Select from the Preview menu to Export Document -> select PDF -> OK -> the Save As window displays with the report file saved with this workorders workorder number plus _SR. as in 75_SR.PDF
[/li][/ul]

How this was done:

[ul]
[li]View the Designer of the report designer for the report template
[/li][li]Via the Property Grid on your left, view for xtraReport1 (if not already showing)
[/li][li]Expand Scripts -> Before Print -> if there is nothign yet set, I select (New). If there is already something showing here, then I go skip and go to the next step.
[/li][li]View the Scripts of the report designer and scroll down to find where the following script was added by the report designer
[/li][/ul]

private void xtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {

}

[ul]
[li]I added the script line as shown with the whole script below.
[/li][li]NOTE it is extremely important that I specify what the exact name is of the band that is bound to WorkorderHeader dataset where the workorder number datafield is identified from.
[/li][li]In this example report template, the band name is DetailReport
[/li][/ul]

private void xtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
xtraReport1.Name= (System.Convert.ToString(DetailReport.GetCurrentColumnValue(“LT_O_Workorder”)))+ “_SR”;
}

[ul]
[li]And I confirm this works by Preview -> Export Document -> select PDF and OK, and the Save As displays the workorder number
[/li][/ul]

It is expected that if you are printing this report from a grid that is displaying multiple workorders, that the file name will display the workorder number of the first workorder, not all workorders.