6 Replies Latest reply on Mar 14, 2013 3:22 PM by delms

    Group on a Calculated String Attribute not working?!?

    Apprentice

      Hi,

       

      I have created a calculation attribute that outputs a string.  The attribute is then used on a query as a group.  The attriute in question is the KPI Status attribute you can see in the final column below.  The query is set to group on this attribute, however, you can see that the group shows all 8 results in the same group of "No KPI Status".  Can anyone think why this might be??  I am expecting to see 3 groups "FAIL", "PASS" and "OPEN"

       

      Capture.JPG

        • 1. Re: Group on a Calculated String Attribute not working?!?
          Expert

          Is this calculated attribute set as "AfterRead"?  If so, this doesn't actually write anything to the database, but will still display something.  I am wondering if your PASS, FAIL etc displays the correct information in the query results, but perhaps grouping is actually polling the database...?  It's just a thought...

          • 2. Re: Group on a Calculated String Attribute not working?!?
            Apprentice

            Ah... yes it is...

             

            Should it be a Before Save then?  I wasn't really sure on the difference but it seemed to be showing stuff on the record! 

            • 3. Re: Group on a Calculated String Attribute not working?!?
              Expert

              It's probably worth a try to change it to BeforeSave, although I'm unsure when/where you want it to be calculated.  It can't hurt to try though I guess.

               

              As I mentioned, I'm not 100% sure that this is the cause though, but it seems a possibility.  Have a look in the sql db table for this attribute, and see if there is any data contained in the field.

              • 4. Re: Group on a Calculated String Attribute not working?!?
                Expert

                I also should mention, that you cannot sort on a calculated attribute, and so this may well apply to grouping on them also.  One way around this may be to use a copy rule to another (non-calculated) attribute.

                • 5. Re: Group on a Calculated String Attribute not working?!?
                  Stu McNeill Employee

                  Just to confirm Paul is correct on this.  After Read calculations are limited in their use because they are processed "on the fly" for display purposes only.  More complex actions like sorting, grouping, etc. are done at a lower level before the calculation is dealt with.

                   

                  You should change it to a Before Save, however you will need to add at least one "depedency" to the calculation and from now on the calculation will only get processed (and save the value to the database) when one of its dependencies gets set/changed.  This is the best practice anyway as it significantly reduces the number of times the calculation itself needs to be processed.

                  • 6. Re: Group on a Calculated String Attribute not working?!?
                    Apprentice

                    It was set up as an after read calculation, I picked up from the community that this might be causing me an issue, however I then changed to a before save calculation and am still getting problems, it is now not populating data if I have a dependency set, or if I don't set up a dependency the attribute doesn't update.

                    I have tried setting the attribute up on the Escalation Point object & Incident object and neither seem to work as required.

                    The calculation is below. I will explain what I am trying to achieve after and maybe you can see where I am going wrong?

                         import System
                         static def GetAttributeValue(EscalationPoint):
                               Value1 = 'PASS'
                               Value2 = 'FAIL'
                               Value3 = 'OPEN'
                               Value4 = 'NON KPI METRIC'
                                    if EscalationPoint.Title == 'Email & Self Service' and EscalationPoint.Status == 'Completed': return Value1
                                    if EscalationPoint.Title == 'Email & Self Service' and EscalationPoint.Status == 'Cancelled': return Value1
                                    if EscalationPoint.Title == 'Email & Self Service' and EscalationPoint.Status== 'Expired': return Value2
                                    if EscalationPoint.Title == 'Email & Self Service' and EscalationPoint.Status == 'Open': return Value3
                                    if EscalationPoint.Title != 'Email & Self Service': return Value4

                     

                    Basically, the calculation is to analyse whether incidents that are logged by auto email or self service are responded to within a 30 minute SLA.  The reason I can't just look at the Status is that when an incident is logged by mail or self service the response level is set at the 30 minute response by the template, which is over written by the SLA Matrix once it has been responded to (the category, urgency & impact set the SLA).  The only exception to this is Quarantined Mail Release requests, which stay on the 30 minute response level.

                    The calculation logic above is correcr, I just can't see why it isn't populating as expected...