Troubleshooting calculation error messages

Version 5

    Verified Product Versions

    Service Desk 7.7.xService Desk 7.8.xService Desk 2016.xAsset Manager 2016.x


    When a calculation fails it always reports an error message.  Normally this error will not display in the client and instead the calculation appears to have worked and returned a blank (null) value.  There are a few ways to find the error message - for more information on how to do that please see this document: Calculations Troubleshooting Guide.  This document explains the causes of the most common error messages, as well as a section at the end with tips on how to find the cause of other messages not documented here.


    "Object reference not set to an instance of an object"

    This is by far the most common error message seen in calculations.  It basically means that you have tried to get the data from something that is not there.  This could be an attribute or one-to-one relationship that is not set, a collection that is empty, or the result of a function that has returned nothing.


    The technical term for "not there", "not set" and "nothing" is NULL.  The calculation writing tutorials have a section dedicated to explaining NULL values in calculations and how to handle them.  Please see the section Checking for NULL values in this tutorial: Calculation Writing Tutorial - 3.  The importance of Indenting and checking NULL values.


    "Could not find attribute type ... . Check metadata catalog."

    This error will occur if you have mis-typed an attribute in the calculation.  The error will include the name of the incorrect attribute (replaced here by '...'), you must find and fix this in your calculation before it will work.


    "Field 'Touchpaper.Framework.Data.DataObjectListProxy....' not found."

    This error will occur when if you are trying to directly reference an attribute on a collection without using any collection function or loop to single out an instance of the collection.  The error will include the name of the incorrect attribute (replaced here by '...'), for example if you try to directly reference the Title attribute from the Notes collection on the Incident object by using Incident.Notes.Title the error will display "Field 'Touchpaper.Framework.Data.DataObjectListProxy.Title' not found.".  This is also the case for many-to-many relationships such as Parent/Child, Incident/Change, Incident/Problem, etc.


    For detailed information on how to reference data from a collection or many-to-many object please see this tutorial: Calculation Writing Tutorial - 4.  Working with Collections and Loops.


    "The method or operation is not implemented."

    This error simply means you are trying to do something that is not supported.  In most cases this will be that you are trying to set the value of an attribute directly within the calculation and probably without even knowing it.


    The following two examples will cause this error:


    Incident.Title = 'My new incident title'


    This is not valid because you cannot set the value of attributes directly in calculations.  A calculation itself returns a value which is used to set the value of an attribute but you cannot set other attributes at the same time.


    if Incident.Title = 'Test': Value = true


    This might look like a valid "if" statement but actually it is doing the same as the first example.  To compare a value in an "if" statement you must have two equals signs and not just one.  Having just one equals sign is actually trying to set the value instead (ie. the first example above).  This is the most common cause for this error to occur and normally just needs an extra equals sign added.


    This is the correct syntax for the above example:


    if Incident.Title == 'Test': Value = true


    "Index (zero based) must be greater than or equal to zero and less than the size of the argument list"

    This error normally refers to improper use of the String.Format() method.  This method is used to create a String made up of one or more variables or object attributes.  When using String.Format() you specify a template with numbered placeholders that look like {0}, {1}, {2}, etc.  These placeholders refer to the other parameters.  The error occurs if you enter a placeholder such as {3} when there are less than 4 parameters (the number is "zero based" so starts at zero).  For more information please see the section String Concatenation using String.Format() in document: Calculation Writing Tutorial - 6.  Working with Strings.


    "Type mismatch when attempting to set attribute value ... ."

    A type mismatch is when the type of data the calculation returned is not suitable for the type of attribute you have created the calculation on.


    Some data type conversion is done automatically for you, for instance a calculation that results in an integer can be used on a Decimal or even String attribute.  However, this isn't always possible.  A prime example of this is trying to put a calculation that results in a DateTime into a String attribute, To overcome this you should re-think the data type of the attribute that you've written the calculation on.  You can also use the ToString() .NET method to force the conversion of any data type to a String, for example:


    Value = DateTime.Now
    return Value.ToString()


    Note this error can occur even if the "Test Calculation" button succeeded.  This is because the calculation itself is working and returning a value.  When the "Test Calculation" button displays the returned value it also shows the value's data type in square brackets before it, for example: Result [DateTime]: 01/02/2013 01:02:03.  This shows that the calculation returned a DateTime value and so must either be used with a DateTime attribute or the calculation modified to convert the data type to something else.


    Function not available at client

    This error will occur when testing a calculation.  It will occur when trying to use certain calculation functions, likely GetBusinessTime() or MinutesToBreach() which require SLA logic to run.  In these cases the calculation might be totally correct but just cannot run in the calculation editor.


    Finding out the cause of an error message not listed here

    Calculations are run in the Microsoft .NET Framework and most error messages are .NET errors that are common to all .NET applications.  This means there is a lot of information available online both from Microsoft and other websites, blogs, and forums.  A simple web search on the error message should provide results.


    If you feel an error message needs to be added to this document please leave a comment below or start a new discussion in this section of the Community.