Problem / Solution: Query showing error: 'Index was outside the bounds of the array' when being run.

Version 11

    Verified Product Versions

    LANDESK Service Desk 7.6LANDESK Service Desk 7.7.x

    Error message:

    When running a query getting error:

     

    System.IndexOutOfRangeException: Index was outside the bounds of the array.

    at Touchpaper.Console.UI.Windows.QueryResultsHelper.GetEnumeratorString(String allowedValues, String value)

    at Touchpaper.Console.UI.Windows.QueryResultsHelper.GetDataObjectString(IClassType rootClassType, Boolean& valueFound, IDataObject dataObject, IQueryAttribute queryAttribute, Boolean isCollectionAttribute)

    at Touchpaper.Console.UI.Windows.QueryResultsHelper.CreateDataGridViewRow(IClassType rootClassType, IDataObject dataObject, IEnumerable columns, Boolean isCollectionAttribute)

    at Touchpaper.Console.UI.Windows.QueryResultsBaseGridView.CreateDataGridViewRow(IDataObject dataObject, Boolean isCollectionAttribute)

    at Touchpaper.Console.UI.Windows.QueryResultData.CreateDataGridViewRows(IEnumerable dataObjectList, BackgroundWorker worker, DoWorkEventArgs e)

    at Touchpaper.Console.UI.Windows.QueryResultData.Populate(IEnumerable dataObjectList)

    at Touchpaper.Console.UI.Windows.QueryResultData.GetFirstPage()

    at Touchpaper.Console.UI.Windows.QueryResultData.SetPagedReader(IPagedDataObjectReader PagedReader)

    at Touchpaper.Console.UI.Windows.QueryPagedDataObjectListControl.SetPagedReader(IPagedDataObjectReader pagedReader)

    at Touchpaper.Console.UI.Windows.QueryResultsControl.SetPagedReader(IPagedDataObjectReader PagedReader)

    at Touchpaper.Console.UI.Windows.ResultsControl.ExecuteQuery(ConsoleQueryBuilder consoleQueryBuilder)

    at Touchpaper.Console.UI.Windows.ResultsControl.Execute()

    at Touchpaper.Console.UI.Windows.ResultsControl.PopulateResults()

    at Touchpaper.Console.UI.Windows.TestQueryPage.PrepareResults()

    at Touchpaper.Console.UI.Windows.TestQueryPage.PopulateResults(Boolean includeConditions)

    at Touchpaper.Console.UI.Windows.QueryDesignerControl.ShowRequestedPage(Pages requestedPage)

    at Touchpaper.Console.UI.Windows.QueryDesignerControl.OnShowPage(Pages page)

    at Touchpaper.Console.UI.Windows.AttributesAndPreviewPage.m_testButton_Click(Object sender, EventArgs e)

    at System.Windows.Forms.Control.OnClick(EventArgs e)

    at System.Windows.Forms.Button.OnClick(EventArgs e)

    at System.Windows.Forms.Button.WndProc(Message& m)

    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

     

     

    Cause:

    This error message happens when running a Queries that show a "Int16" or "Int32" Attribute where the value is NULL in the result.

    This is logged as problem 5427.

     

     

    Workaround:

     

    1. Set a default value on Int16 or Int 32 attributes.

    DefaultValue.jpg

     

    2A. Go into database and replace Null values with 0. In this case it was the usr_incidentsurvey table and I had to change the null values for Question 1 through Question 5 to 0's. You can use a basic update statement:

    UPDATE usr_incidentsurvey
    SET usr_question1 = 0
    WHERE usr_question1 IS NULL
    

     

    DB.jpg

     

    2B. Set the attribute to be Mandatory in Object Designer and with this fill in a Backfill value, meaning that you will not need to run the above SQL script to set a value in the attribute as this will be done for you.

     

    Solution:

    This was reported as Problem 5427 and fixed in the version 7.8.