IGlobalErrors.GlobalErrorMessage Property
The GlobalErrorMessage and GlobalErrorNumber properties represent a pair which is always set together.
Remember that GlobalErrorMessage and MessageStack are completely independent and they are used by different methods in the API. So to determine whether any global error was reported in the old way, you should test GlobalErrorMessage first. If it is empty, it doesn't mean there was no error. In such a case, you need to test whether MessageStack contains any item.
The following methods that don't throw exceptions and instead set the GlobalErrorMessage property. These methods usually return null reference (Nothing in Visual Basic) on failure. To get the error details, check GlobalErrorMessage property.
IArticleDatabase.GetArticleFieldValue
IArticleDatabase.SetArticleFieldValue
IBoq.GetCellValueFromWorkbook
IOverhead.GetCellValueFromWorkbook
IWbs.GetCellValueFromWorkbook
ISharing.GetFullInformationForAllUsers
IMinute.GetFieldValue
IMinute.SetFieldValue
IEstimateVersion.RefreshAll
IWbs.Refresh
IEstimate.RepaintCurrentView
IGlobalVariables.SetVariableValue
IEstimate.GetActiveMinuteWorkbook
IAnalyticReporting.GetDataSource
IMinute.GetFullData
IWbs.GetFullData
IAnalyticReporting.GetImageOfFieldsForDataSource
IOverhead.GetLockOnWorkbook
IGlobalVariables.GetVariableValue
IEstimate.IsConnectedToManagement
IMinute.UpdateValuesConditionally
IEstimate.CheckAndRepaint
IMinute.ClearRowValues
IArticleDatabase.Close
IArticleDatabase.DeleteArticle
IArticleDatabase.ExportToExcel
IEstimate.MoveCursorToMinuteRowColumn
IWbs.RemoveAllLinks
IArticleDatabase.SetArticleFieldValue
IWbs.SetColumnBackgroundColor
IWbs.SetColumnFormula
The following example shows, how to correctly handle errors from IAnalyticReporting.GetDataSource method which uses the old error handling.
' get the data source workbook Dim aTools As IAnalyticReporting = Es.CurrentVersion.GetAnalyticReportingTools() Dim fields As List(Of FieldForQdvFldConfigFile) = aTools.GetImageOfFieldsForDataSource("C:\data_source_fields.qdvfldconfig", collapsed) Dim dataSourceWorkbook As IWorkbook = aTools.GetDataSource(fields, False) ' Check the errors, because GetDataSource doesn't throw exceptions. If dataSourceWorkbook Is Nothing ' an error occurred, get the details If Not String.IsNullOrEmpty(Context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage) ' The error is reported in GlobalErrorMessage. Dim errText As String = Context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) ElseIf Context.QdvManager.Environment.GlobalErrors.MessageStack.Count > 0 ' The error(s) is/are reported in MessageStack, display them all. Dim errText As String = "" For Each err As String In Context.QdvManager.Environment.GlobalErrors.MessageStack errText &= err & vbCrLf Next MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) Else ' no error details End If End If
This language is not supported or no code example is available.
IAnalyticReporting aTools = es.CurrentVersion.GetAnalyticReportingTools(); // Get all available fields for data source and where applicable, set their "All levels" to True. IEnumerable<FieldForQdvFldConfigFile> fields = aTools.GetAvailableFieldsForDataSource(useEightLevelsWhereApplicable: true); // Now you can customize or remove individual fields, if needed. // Save the fields configuration into a qdvfldconfig file. This is an optional step. bool collapsed = true; aTools.SaveFieldsForDataSource(@"C:\test.qdvfldconfig", fields, collapsed); // Create the data source. IWorkbook dataSourceWorkbook = aTools.GetDataSource(new List<FieldForQdvFldConfigFile>(fields), collapsed); // Check the errors, because GetDataSource doesn't throw exceptions. if (dataSourceWorkbook == null) { // An error occurred, get the details. if (!String.IsNullOrEmpty(context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage)) { // The error is reported in GlobalErrorMessage. string errText = context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage; MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (context.QdvManager.Environment.GlobalErrors.MessageStack.Count > 0) { // The error(s) is/are reported in MessageStack, display them all. string errText = ""; foreach (string err in context.QdvManager.Environment.GlobalErrors.MessageStack) { errText += err + "\n"; } MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // No error details. } }
This language is not supported or no code example is available.