1 2 Previous Next 22 Replies Latest reply on May 31, 2018 11:44 PM by Julian Wigman

    Stop/Start Clock Attribute?

    Pitmac1 Apprentice

      Hey ServiceDesk Pals,

       

      Correct me if i'm wrong, but isn't there an "Stop/Start Clock" Attribute that you are able to pull to determine the amount of time a record it took to resolve (min)?

       

      Currently I would like to run a report on incidents that have been closed within a hour, but the incidents that were in a pending status need to have the clocked stopped then started back up after leaving that pending state. I have the process designed to stop the clock and start the clock, but I'm not sure which attribute this is to pull from?  Is this possible? 

        • 1. Re: Stop/Start Clock Attribute?
          Julian Wigman ITSMMVPGroup

          Pitmac1 there is the GetBusinessTime function you can use in a Boo calculation and you’d pass in Create datetime and Resolution datetime as parameters and this would return a timespan that you can then extract your support minutes from.

           

          Note that this function only works apif the lifecycle has a Response Level assigned to it!

           

          Julian

          MarXtar Ltd

          • 2. Re: Stop/Start Clock Attribute?
            Pitmac1 Apprentice

            I think I'm missing the part where the life cycle has a Response Level assigned to it. Where would I go to check this? I assume Administration ->  Administration -> Service Level Management

            • 3. Re: Stop/Start Clock Attribute?
              Julian Wigman ITSMMVPGroup

              Pitmac1  Yes you have the correct path for where SLM is setup and specifically Calendars, Response Levels, Escalations And Escalation Points are setup.

               

              What I mean though is does the Incident window itself have a Respone Level field on it and has that been set either manually or via the Service Level Matrix rules.

               

              It needs to have a Response Level so that it knows the support hours from the calendar etc.

               

              Also I don’t believe the function works in test mode so better to try it for real on an attribute.

               

              Finally you can see from above the result is a timespan; you actually need to return components of this ie

               

              Value.Minutes

               

              See TimeSpan Structure (System)  for more on this method and the components of a timespan.  The Calculations section of the forum is good too for some “cookbook” info on working with Timespans.

               

              Julian

              MarXtar Ltd

              • 4. Re: Stop/Start Clock Attribute?
                Pitmac1 Apprentice

                Thanks, I'll try it. I also assume that the "Response level" field on the incident window will also need to have an default Response level for this to work?

                So far I have the following:

                - Value.Minutes in the Boo clock

                - Support Calendar

                - Default Response Level for Incidents, but It doesn't appear to be defaulting when creating an incident. (problem?)

                - Attribute to calc support time on the Resolution Window

                • 5. Re: Stop/Start Clock Attribute?
                  Pitmac1 Apprentice

                  Alright I think I'm making progress. I didn't have an Response Agreement for Standard Incidents, so I created one and now all incidents have an Response Level associated with it.

                   

                  In this case it is:

                  There really isn't a need for the color change. Just for testing.

                   

                  So if all incidents receive this now then I should be able to pull the GetBusinessTime function now right? Well maybe not since the attribute I have is Int32 and the Test is saying Double value. I understand that this function will not work in test, but if I create an incident and close it, shouldn't I at least have a value.

                  • 6. Re: Stop/Start Clock Attribute?
                    Julian Wigman ITSMMVPGroup

                    Pitmac1 maybe checkout some of the other firum threads on getbusinesstime such as Re: GetBusinessTime doesn't work

                     

                    I’m wondering if it is something to do with you calling this function from the Resolution object and not from the base Incident object itself.  Personally I would set this as an attribute on the Incident object itself and then you can still show on the Resolution object window if needed.

                     

                    Julian

                    MarXtar Ltd

                    • 7. Re: Stop/Start Clock Attribute?
                      Julian Wigman ITSMMVPGroup

                      Pitmac1 ah it might be simpler than that, I think you have your 2 parameters the wrong way around in the function. Try with Incident creation date as first parameter and the resolution date as the second one.

                       

                      Julian

                      MarXtar Ltd

                      • 8. Re: Stop/Start Clock Attribute?
                        Julian Wigman ITSMMVPGroup

                        Pitmac1 did switching the order of the parameters work?

                         

                        Julian

                        • 9. Re: Stop/Start Clock Attribute?
                          Pitmac1 Apprentice

                          JulianWigman

                          A couple of items.

                           

                          1. I tried to swap the parameters from my Resolutions attribute "Support Time" with Calc.

                          import System

                          static def GetAttributeValue(Resolution):

                          Value = Resolution.Incident.GetBusinessTime(Resolution.Incident.CreationDate , Resolution.CreationDate )

                          return Value.TotalMinutes

                           

                          After doing so, nothing happened.

                           

                          2. I followed your link and found out maybe you are right. Maybe the function only works on the Incident window. I also found that according to How to calculate the "business time" of an incident  that the calculation was returned as a String.

                           

                          I created a attribute called "Support Time" (String 300), Before Save, with the following calc.

                          import System

                          static def GetAttributeValue(Incident):

                          Value = Incident.GetBusinessTime(Incident.CreationDate, Incident.Resolutions.CreationDate)

                          return String.Format("{0}Hour(s), {1}Minute(s), {2}Second(s)", Math.Floor(Value.Totalhours), Value.Minutes, Value.Seconds)

                           

                          With dependencies: CreationDate

                           

                           

                          However i'm still receiving the same result.

                           

                          One thing I haven't tried yet is changing the my attribute under the Resolution BO to a String Attribute instead of an Int32. And try the calc:

                            TimePeriod = Resolution.Incident.GetBusinessTime(Resolution.Incident.CreationDate, Resolution.CreationDate)
                               return String.Format("{0} Hour(s), {1} Minute(s), {2} Second(s)", Math.Floor(TimePeriod.TotalHours), TimePeriod.Minutes, TimePeriod.Seconds)

                          • 10. Re: Stop/Start Clock Attribute?
                            Julian Wigman ITSMMVPGroup

                            Pitmac1  Firstly the return values shouldn't be a string though the calc maybe trying to convert to that if the destination attribute is a string.  It should return a TimeSpan object and you pick whatever you need from that and depending on what the destination attribute expects; for example Value.Minutes should go into an Int32 fine.

                             

                            Re your dependency. If you have on the Incident object now the dependency needs to be the Resolution object as you want it to trigger when a resolution is created.

                             

                            Julian

                            MarXtar Ltd

                            • 11. Re: Stop/Start Clock Attribute?
                              Julian Wigman ITSMMVPGroup

                              Pitmac1 also see How to calculate the "business time" of an incident  and you now have the parameters in the correct order.

                               

                              If you just want to return the minutes you can round teh decimal "TotalHours" to integer ie.

                               

                              return Math.Floor(Value.TotalHours)

                               

                              Julian

                              MarXtar Ltd

                              • 12. Re: Stop/Start Clock Attribute?
                                Pitmac1 Apprentice

                                Update:

                                 

                                I found a comment in the document How to calculate the "business time" of an incident  where a user created a String Attribute  (300) under the Incident Window with a After Read Calculation Type and using the Calculation Formula:

                                 

                                import System

                                static def GetAttributeValue(Incident):

                                     Count = Incident.Resolutions.Count

                                     if Count < 1:

                                     TimePeriod = Incident.GetBusinessTime(Incident.CreationDate, DateTime.UtcNow.ToLocalTime())

                                     if Count > 0:

                                     TimePeriod = Incident.GetBusinessTime(Incident.CreationDate, Incident.Resolutions.Latest().CreationDate)

                                     return String.Format("{0} Hour(s), {1} Minute(s), {2} Second(s)",Math.Floor(TimePeriod.TotalHours), TimePeriod.Minutes, TimePeriod.Seconds)

                                 

                                Since I wanted to query the amount of time after 1 hour, I decided to use Decimal data type. Checked Decimal Places as 2. Placed After Read Calculation Type and using the Calculation Formula:

                                 

                                import System

                                static def GetAttributeValue(Incident):

                                     Count = Incident.Resolutions.Count

                                     if Count < 1:

                                     TimePeriod = Incident.GetBusinessTime(Incident.CreationDate, DateTime.UtcNow.ToLocalTime())

                                     if Count > 0:

                                     TimePeriod = Incident.GetBusinessTime(Incident.CreationDate, Incident.Resolutions.Latest().CreationDate)

                                     return Math.Floor(TimePeriod.TotalHours)

                                 

                                 

                                This appears to be working with my calendar (8-5 M-F). So YAY!

                                 

                                However, now i'm presented with another issue. I am being asked to Stop the clock if the incident enters a Pending Status then Start again when exiting the status. I was under the impression that GetBusinessTime follows the escalation clock. I thought if you had an incident as a P1 and in 30mins of inactivity a notification will go to the manager, however if that incident was to go to "In Repair" then the notification would not deliver.  I guess I'm wrong regarding the escalation clock.

                                Is there a better way for this?

                                 

                                I saw an document Time to Resolution report (replacement for Incident Duration By Days report)  that may help, but i'm not sure if I wanna go down the Crystal Reports road. If this is better done in Xtraction, then I'll post this in that form.

                                • 13. Re: Stop/Start Clock Attribute?
                                  Julian Wigman ITSMMVPGroup

                                  Pitmac1 As previously asked here it would seem manually capturing the stoppage time in a collection is the way to go and then subtracting from GetBusinessTime value. So create a collection item when you enter clock stopped and one when you exit (via automatic actions) and ”type” the entries so you know which are start and stop, then have a calc that adds up time based around the create datetimes of the ”typed” collection item pairs (stop & start). it isnt going to be much use for retrospective transactions though.

                                   

                                  Re: Is it possible to report on resolved time taking into account the business time and excluding actions that stop the clock?

                                   

                                  The Crystal method referred to doesn't do anything special other than use some SQL functions originally written by the (at the time Touchpaper) Systems Integration Team so no reason these could not be used elsewhere; I’ve certainly used in SSRS reports in the past.

                                   

                                  Sometimes ServiceDesk does seem to overcomplicate/miss the most simplest of use case requirement!  

                                   

                                  Julian

                                  MarXtar Ltd

                                  • 14. Re: Stop/Start Clock Attribute?
                                    Pitmac1 Apprentice

                                    Alright Lets try this:

                                     

                                    1. I created two Collection within Incident Management -> Incident:

                                         a. Start Time

                                              i. Start Time BO has a DateTime Attribute (Start Time)

                                         b. Stop Time

                                              i. Stop Time BO has a DateTime Attribute (Stop Time)

                                    2. I have created two automatic actions

                                         a. Start Time

                                         b. Stop Time

                                         I followed the example posted from Creating a Window associated Process Action

                                    3. Then I created a Decimal Attribute within Incident Management -> Incident called:

                                             a. Total Support Time

                                                   i. After Read Calculation

                                     

                                    Okay I know this calc is most likely wrong but would this Calc work for Grabbing the Total Stop Time and subtracting it from the Get Business Time?

                                     

                                    import System

                                    static def GetAttributeValue(Incident):

                                         Count = Incident.Resolutions.Count

                                         if Count > 0:

                                              GetStopClock = Math.Floor(Incident._StartTimeCol.Latest() - Incident._StopTimeCol.Lastest())

                                              GetStopClock = GetStopClock++

                                         if Count < 1:

                                              Value = Incident.SupportTime2 - GetStopClock

                                    return Value

                                     

                                    I'm not sure how to continually add time to GetStopClock when there is not a resolution.

                                     

                                    I know I will still have to add the automatic actions to my process and this to my window, but would this Calc work?

                                    1 2 Previous Next