Calculation formula writing: Further reading on the Boo scripting language and .NET Framework

Version 1

    Verified Product Versions

    LANDESK Service Desk 7.6LANDESK Service Desk 7.7.xLANDESK Service Desk 7.8.xLANDESK Service Desk 2016.x

    As described in the Calculations documentation all formulae in Service Desk is written using the Boo scripting language.  Each calculation formula is essentially a function written in Boo, the result of which is used as the Service Desk attribute value.

     

    Support is not provided for the writing of calculations. However, the following links may be of use in learning how to achieve more advanced formulae.  All information is provided "as is".

     

    More information on the Boo language

     

    The official website for Boo is: http://boo-lang.org/

     

    On the website, there are some good tutorials to introduce the language at https://github.com/boo-lang/boo/wiki

    The Boo Primer is a good tutorial and general reference guide: https://github.com/boo-lang/boo/wiki/Boo-Primer

     

    The tutorials cover a lot of information which is not relevant to Service Desk calculations, but some good chapters on the Boo Primer are those on Variables, Flow Control and Operators.

     

    More information on the .NET Framework

     

    The Boo language has access to the .NET Framework classes and methods.  This means a lot of the code you can write in a calculation formula for complex mathematical operations or string manipulation etc. is calling a .NET method.  The Microsoft MSDN website has a full .NET reference guide, some useful sections are:

     

    Math methods: http://msdn.microsoft.com/en-us/library/system.math_methods.aspx

    This page lists all the available methods you can perform on a number (int or decimal attribute or variable).  For example to take a decimal and round it to its lowest integer you can use the Math.Floor() method: Value = Math.Floor(Incident._MyDecimal)

     

    String methods: http://msdn.microsoft.com/en-us/library/system.string_methods.aspx

    This page lists all the available methods you can perform on a string attribute or variable in a calculation.  For example to return the first five characters of the Incident.Title attribute you can use the SubString() method: Value = Incident.Title.SubString(0,8)

     

    DateTime methods: http://msdn.microsoft.com/en-us/library/system.datetime_methods.aspx

    This page lists all the available methods you can perform on a DateTime attribute or variable in a calculation.  For example to return a DateTime of a week from now you can use the AddDays() method: Value = DateTime.Now.AddDays(7)

     

    As the .NET Framework covers multiple programming languages there is a lot of information freely available online.  The MSDN links are a good (and official!) reference guide but don't suit well as tutorials as most pages don't include examples.  If you know the method you need to use but unsure how/when to use it a web search on ".NET" followed by the method name will normally provide some good results.