11 Replies Latest reply on Nov 9, 2011 10:08 AM by Stu McNeill

    Calculation attribute on resolution


      Is it possible to add a calculation attribute on the resolution object to show the time it took to close a ticket ?


      Basically the Resolution Create Date minus the Incident Create Date.


      I've tried to get this to work in the test environment to put it on a query, but the result is blank.


      I've tried tracing, but the log doesn't get created.  I must be missing something.


      Has anyone tried something similar ??

        • 1. Re: Calculation attribute on resolution
          Adam Wilden Expert

          Here's what we are using for exactly that:



          Design Element:  OBJECT - Incident Resolution
          Calculation Type:  BeforeSave
          On attribute:  BusinessHours

          New attributes: BusinessHours (string)

          Dependencies: CreationDate, Incident

          import System
          static def GetAttributeValue(Resolution):
          TimePeriod = Resolution.Incident.GetBusinessTime(Resolution.Incident.CreationDate, Resolution.CreationDate)
          return String.Format("{0} Day(s), {1}h, {2}m, {3}s", TimePeriod.Days, TimePeriod.Hours, TimePeriod.Minutes, TimePeriod.Seconds)

          Purpose:   Calculates how much Business time an Incident has been open for.




          We have another that doesn't restrict to business hours if of any help.

          • 2. Re: Calculation attribute on resolution

            Hi Adam,


            Thank you for the reply.  I found the same code you listed in a thread between you and Stu.


            I created the attribute as a String(50) and BeforeSave Calc Type on the Resolution object.


            The dependencies are CreationDate and Incident.  The sytax tests just fine.  However, when I run a query on the Resolution object including the new attribute, it comes up blank.


            Any ideas ??  I've attached a screen shot of the calc screen...

            • 3. Re: Calculation attribute on resolution

              After Day(s) you have a ";" and not a comma.



              return String.Format("{0} Day(s); {1}h,  {2}m, {3}s", TimePeriod.Days, TimePeriod.Hours, TimePeriod.Minutes,  TimePeriod.Seconds)



              • 4. Re: Calculation attribute on resolution

                Thanks Carl.  After I updated the formula, however, the field was still blank in the query.


                So, thinking maybe it was something else I created a new incident and resolved it.


                I assumed the field would appear in the query for old tickets as well, but it didn't, just the new ones going forward.


                Thanks again for the proof read.... 

                • 5. Re: Calculation attribute on resolution
                  Adam Wilden Expert

                  Glad you've got it working.


                  You can now run the calculation in a bulk action query to update existing records....

                  • 6. Re: Calculation attribute on resolution



                    I've gotten everything to work as described by yourself and Adam, but have not been able to update the attribute in the old incidents using the Bulk Action Query.  Please help.

                    • 7. Re: Calculation attribute on resolution

                      I use 7.3.1 and it seems to me that existing incidents don't calculate but any new incidents will calculate. I think that when I tested it on 7.4 I had no issues.  It's been a long time since I last did this but you might look to see if any new incidents calculate fine.

                      • 8. Re: Calculation attribute on resolution
                        Adam Wilden Expert

                        Here's what we did:


                        In Business Objects we temporarily changed the  calculation type from "Before Save " to "Scheduled".


                        Then we created a query against Resolution selecting all for the past 3 months.


                        Then we used the bulk action scheduler under Administration to run that calculation against the new query.


                        Once run we changed the query to earlier dates (only ever doing 3 months at a time as we resolve lots of calls!)


                        Fairly certain this was done using 7.3



                        Cheers - Adam.

                        • 9. Re: Calculation attribute on resolution

                          Thanks for your help guys.  I'm finding that when I set my TimeToClose(created following your instructions) attribute to AfterRead, my queries of old incidents show the correct values and the new incidents are updated as well.  Could there be a problem with leaving the attribute as AfterRead?  I'm running 7.3.2.




                          • 10. Re: Calculation attribute on resolution
                            Adam Wilden Expert



                            I believe that "After Read" calculates in real time every time you open the form on which the field resides.


                            I don't believe this is sticky, database wise,  but should serve your purposes.


                            There may be some performance hit in this though.


                            I imagine it depends on how often you need to run queries and reports based on such an attribute.


                            Could be wrong though


                            Cheers - Adam.

                            • 11. Re: Calculation attribute on resolution
                              Stu McNeill Employee

                              Adam is correct here.  AfterRead calculations will work but get processed every time you view the data so has a performance overhead, plus the data is not always stored in the database so cannot be used by any 3rd party reporting.  We generally discourage using them as their only benefit is for time-based calculations that are constantly changing (ie. how long before the SLA breaches, etc).


                              Could you elaborate on what problems you had when you tried to do the schedule to back-fill the existing records?