This script is called before the selected report is run. You can use this to change the report or output properties, or to prevent the report from running for some reason.

Parameters
A reference to the Stonefield Query Application object, the name of the report, the output type ("PREVIEW," "PRINTER," "FILE," or "EMAIL"), the output file name (blank unless the output type is "FILE"), and a reference to a Report object for the report.

Return Value
True if the report run can continue, False to cancel the run.

Example
Here's an example that logs when a report is run.

Visual FoxPro

lparameters toApplication as SQApplication, tcReportName, ;
  tcOutputType, tcOutputFileName, toReport as Report
strtofile(tcReportName + ' started by ' + ;
  SQApplication.Users.UserName, 'reportlog.txt')
return .T.

VBScript

function Main(Application, ReportName, OutputType, _
  OutputFileName, Report)
dim fso, ts
const ForWriting = 2
set fso = CreateObject("Scripting. FileSystemObject")
set ts = fso.OpenTextFile("reportlog.txt", ForWriting, True)
ts.WriteLine(ReportName + " started by " + Application.Users.UserName)
ts.Close
Main = true
end function

JavaScript

function Main(Application, ReportName, OutputType, 
  OutputFileName, Report) {
var fso, ts ;
var ForWriting= 2 ;
fso = new ActiveXObject("Scripting.FileSystemObject") ;
ts = fso.OpenTextFile("reportlog.txt", ForWriting, true) ;
ts.WriteLine(ReportName + " started by " + Application.Users.UserName) ;
ts.Close ;
return true;
}

C#

Please note that the method in this script must be named ReportEngine_BeforeRunReport.

public static void ReportEngine_BeforeRunReport(SFQApplication sfqApplication, 
  string reportName, string outputType, string outputFileName Report report)
{	
  StreamWriter writer = new StreamWriter("reportlog.txt");
  writer.WriteLine(reportName + " started by " + sfqApplication.Users.UserName);
  writer.Close();
  return true;
}

VB.NET

Please note that the method in this script must be named ReportEngine_BeforeRunReport.

public shared function ReportEngine_BeforeRunReport(sfqApplication as SFQApplication, _
  reportName as string, outputType as string, outputFileName as string,
  report as Report) as Boolean
  Dim writer as StreamWriter = new StreamWriter("reportlog.txt")
  writer.WriteLine(reportName + " started by " + sfqApplication.Users.UserName)
  writer.Close()
  Return True
End Function

See also

ReportEngine.AfterReportPrepared | ReportEngine.AfterRunReport | ReportEngine.BeforeCreateFile | Report Object | Scripts

© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic