Consider the below IronPython script which performs an Export To Pdf:
# Get the prepared report
result = Application.Document.TryGetReport("Weekly Sales report")
# Check result
if result[0] == True:
# Export the PDF
report = result[1]
exportResult = report.ExportToPdf("c:\\Source\\test.pdf")
The above script runs alright when executed from Analyst as well as from Web Player.
Note: It requires that the "Execute in Transaction" option is un checked.
As such all IronPython scripts are executed in transaction, and hence any code that starts a progress or aggregated transaction will fail unless the check box "Execute in Transaction" is unchecked.
However the above script fails with below exception if
triggered from Automation Services irrespective of whether the script has the 'Execute in transaction' option unchecked.
System.InvalidOperationException: Invalid operation 'BeginAggregatedTransaction' to the command history when in state 'Executing'.
at Spotfire.Dxp.Framework.Commands.CommandHistory.BeginAggregatedTransaction(String displayName, Boolean transient, DocumentNode node)
at Spotfire.Dxp.Framework.DocumentModel.DocumentNode.BeginTransientTransaction()
at Spotfire.Dxp.Application.Export.PreparedExportReport.PreparedExportReport.BuildResultCache(Nullable`1 maxRepetitions)
at Spotfire.Dxp.Web.Export.PreparedExportReportBuilder.BuildForExport(PreparedExportReport preparedExportReport)
at Spotfire.Dxp.Web.Export.ReportExporter.Export(Report report, Stream outputStream, String& errorMessage)
at Spotfire.Dxp.Application.Export.Report.ExportToPdf(Stream outputStream)
at Spotfire.Dxp.Application.Export.Report.ExportToPdf(String fileName)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)“