0 Replies Latest reply on Dec 30, 2015 2:00 PM by sismeya

    Decimal Trailing Zeros - Workaround

    sismeya Rookie


      I was trying to add Prices to the Service Catalogue items, but when they displayed in the report template they displayed trailing zeros (11.9900000000000)

      I couldn't find any examples on the Forum so I thought I would post an example of a workaround for the trailing zero issue when using decimals, sorry if this has already been posted !!


      I ceated an additional calculated value  attribute - PriceString - this reads the value, rounds the value up to 2 decimal places and then converts to a string.


      Calculation - Before Save




      import System

      static def GetAttributeValue(ConfigItem):

      Value = ConfigItem._Price

      result=Math.Round(Value, 2, MidpointRounding.AwayFromZero)

      stringVal = System.Convert.ToString(result)

      return stringVal