7 Replies Latest reply on Jun 10, 2015 12:53 PM by AmyS

    Adding a resolution date to a query

    Jamie Cannon ITSMMVPGroup

      I am trying to add the resolution date to a query but when I try to add "Resolutions --> CreationDate" it adds it as a tab instead of a column.  Am I missing something?

       

      Thanks,

        • 1. Re: Adding a resolution date to a query
          aparker Employee

          Hi Jamie,

           

          Yup, you are!

           

          Resolution is a collection on Incident and as such can have a one to many relationship. This is why when you add it to a query written on  Incident it is shown as a tab, the same as Notes for example. What you have to do is to create a query that is written on the Resolution object and then bring on the Incident attributes as they are a related set.

           

          Hope that helps.

           

          Andy

          • 2. Re: Adding a resolution date to a query
            Jamie Cannon ITSMMVPGroup

            Thank you sir.  I will give that a shot right now.

            • 3. Re: Adding a resolution date to a query
              dmshimself ITSMMVPGroup

              You will still give several rows if there has been more than one resolution on the incident and that might be just fine for you.  As an extra alternative you could write a calculation for an attribute on the incident object which just copies the date of the resolution.  Set depencies on resolutions and that will give you a date field on the incident which always shows the date of the latest resolution or is empty if it hasn't been resolved.  Add another calculated field for resolution description and you can show that too.

              • 4. Re: Adding a resolution date to a query
                Apprentice

                Can you please suggest how this calculation would look like? A tried with:

                 

                import System

                static def GetAttributeValue(Request):

                     Value = Request.Resolutions.Latest()

                     if Value != null:

                          return Value.CreationDate.ToString()

                     else:

                          return ""

                 

                I tried with both After Read and Before Save and it is not working in query. But when I test calculation it works. Thank you!

                • 5. Re: Adding a resolution date to a query
                  Jamie Cannon ITSMMVPGroup

                  Maybe something like this would work?  This is looking through all resolutions in the collection and picking out the latest one.  I have seen the .Latest() act a little weird sometimes so maybe looping through first will help.

                   

                  import System

                  static def GetAttributeValue(Request):

                       Value = ""

                       for resolutions in Request.Resolutions:

                            if resolutions != null:

                                 Value = resolutions.Latest().CreationDate.ToString()

                   

                      return Value

                  • 6. Re: Adding a resolution date to a query
                    Apprentice

                    Thank you Jamie, but when I test calculation you suggested I get the following error:
                    Capture.JPG

                    • 7. Re: Adding a resolution date to a query
                      AmyS Apprentice

                      Hi vdole - Give the below calculation a try. I got this to work in our environment:

                       

                      import System

                      static def GetAttributeValue(Incident):

                           Value = ""

                           for Resolutions in Incident.Resolutions:

                                if Incident.Resolutions != null:

                                     Value = Incident.Resolutions.Latest().CreationDate.ToString()

                       

                          return Value