3 Replies Latest reply on Oct 26, 2014 9:31 AM by AdamWilden

    Calculating time Since Breach

    Expert

      Hi Guys,

       

      My Service Desk want a new attribute within LANDesk showing time in minutes SINCE breach when a call is resolved..

       

      This is a simple calc:

       

      import System

      static def GetAttributeValue(Resolution):

      TimePeriod = Resolution.Incident.GetBusinessTime(Resolution.Incident.BreachTime, Resolution.CreationDate)

      Varmins =  Int32.Parse(String.Format("{0}", Math.Floor(TimePeriod.TotalMinutes)))

      return Varmins

       

      This works well but they have now asked if it could show the time LEFT until Breach in the same field, if the call didn't breach.

       

      I'm not sure whether the GetBusinessTime function simple compares the two dates, but if I put in a condition saying Incident.IsBreached = False and then simply reverse the order of the dates then nothing is returned.

       

       

      Any ideas/help appreciated.

       

      Thanks.

        • 1. Re: Calculating time Since Breach
          Stu McNeill Employee

          Hi Adam

           

          The GetBusinessTime() function simply compares the two dates you give it, taking in to account the calendar for the current response level.  You should be able to swap the parameters around so I'm not sure why that isn't working.  What exactly does happen?  Does GetBusinessTime() return null or are there any errors if you enable calculation diagnostic logging?

          • 2. Re: Calculating time Since Breach
            Expert

            Hi Stu,

             

            It returns nothing.  When I add a "+ 1" to the end of the return string I still get nothing which suggests an error rather than a null value.

             

            Unfortunately, due to the way the Dev servers were set up on a Hyper-V cluster I don't have rights (even as an admin) to enable logging (and won't do so until it is migrated to ESX) - don't even ask...:)

             

            If I try the Test button I get "function not available at client"...

             

            As it's an int32 field I can't use Try/Catch either. 

             

            import System

            static def GetAttributeValue(Resolution):

            TimePeriod = Resolution.Incident.GetBusinessTime(Resolution.CreationDate, Resolution.Incident.BreachTime)

            Varmins =  Int32.Parse(String.Format("{0}", Math.Floor(TimePeriod.TotalMinutes))) + 1

            return Varmins

             

            Dependencies I've added are Incident and CreationDate.

             

            Any other ideas?  Has anyone else tried this?

             

            Thanks.

            • 3. Re: Calculating time Since Breach
              Expert

              Still no joy on this one.

               

              Calc error logging shows an "Object not set..." error whenever I run the above calculation on a non-breached call (whichever way round the dates are).

               

              So I've tried different methods (such as below) but still can't find a way of recording time left until breach when resolving incidents.

               

              I don't seem to be able to use the MinutestoBreach function from the Resolution object.

               

              [Before Save calc on Int32 - "Minutes left on SLA at Resolution"]

               

              import System

              static def GetAttributeValue(Resolution):

                   if Resolution.Incident.IsBreached.ToString() == 'False':

                        if Resolution.Incident.MinutesToBreach() != null:

                             return Resolution.Incident.MinutesToBreach()

                        else:

                             return Resolution.Incident.ResponseLevel.TurnaroundTime

                  else:

                     TimePeriod = Resolution.Incident.GetBusinessTime(Resolution.Incident.BreachTime, Resolution.CreationDate)

                     Varmins = Int32.Parse(String.Format("{0}", Math.Floor(TimePeriod.TotalMinutes)))

                     return Varmins * -1

               

              Am I doing something stupid? 

               

              For the time being I will just record times against *breached* calls on resolution but it seems a shame we can only record this info for the SLAs we missed, not the ones we met.

               

              Cheers.