1 2 Previous Next 24 Replies Latest reply on May 15, 2015 1:22 AM by GarethReeves

    Unresolve decision based on created by

    GarethReeves Apprentice

      I need to add an assignment when the unresolved action is taken that uses a decision to work out who is taking the un resolve action. if end user the assigns to a group if not end user then add assignment to the Lastupdatedby record.

       

      What happens if the Analyst unresolves this correct assigns to the lastupdated by which is was the analyst as they used the un resolve action, if the end user uses the unresolve it sets the assignment to the end user and not the helpdesk group.]

       

      To me this means the last updated by on the unresolve is not being returned in the decision so nothing equals user type End User.

       

      1.png2.png3.png

      As far as I can see last updated by is populated just the decision is not seeing it, Any ideas?

       

      Thanks, Gareth

        • 1. Re: Unresolve decision based on created by
          Jamie Cannon ITSMMVPGroup

          It almost sounds like you need to capture the Unresolve.CreatedBy.UserType instead of the last updated by.  I feel like the last updated by you are using there is going to pull the last updated by for the original ticket.  Given this, you may have to use a calculation to capture this decision value.  I think you'll need to use a calculation because unresolves is a collection so you'll need to be able to sift out the latest one in the event there are many.  I can't test this right now but this should get you pointed in the right direction.

           

          Something like:

           

          Value = false

           

          CurrentUser = Incident.GetCurrentUser

          CurrentUserTitle = Incident.GetObjectByAttribute("System.User","Name",CurrentUser)

           

          if Incident.UnResolvesCollection != null:

               Unresolves = Incident.Unresolves.Latest()

               if Unresolves.LastUpdatedBy != null:

                     UserType = Unresolves.LastUpdatedBy.UserType.Title      <---- this line I'm not sure if you'll need the Title or Name attribute.  Might have to test this.

           

          if UserType == "Analyst":

               Value = true

          else:

               Value = false

           

          return Value

           

          Once you have added the calculation, your condition would be "equals" true to finalize it.

           

          I hope this helps in some way.

          • 2. Re: Unresolve decision based on created by
            GarethReeves Apprentice

            Thanks, I tried the calculation errors doesn't seem to like "incident." Any Ideas? I will keep tinkering with it.

             

            Calc_Error.png

            • 3. Re: Unresolve decision based on created by
              GarethReeves Apprentice

              OK fixed the ridiculous indenting and got the calc to run without error when testing. Set equals true as the condition and tried the process, as soon as I try the unresolve action I get, XML error!

               

              Any Ideas?

               

              at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

              at Touchpaper.Framework.Data.SDataObjectRef.Parse(String xml)

              at Touchpaper.Framework.Data.DataObject.ConvertValueFromString(DataType dataType, String value)

              at Touchpaper.Framework.Data.DataObject.CompareConditionValues(DataType dataType, String valueString, Object attributeValue, ICondition condition)

              at Touchpaper.Framework.Data.DataObject.EvaluateCalculationCondition(ICondition condition)

              at Touchpaper.Framework.Data.DataObject.EvaluateCondition(ICondition condition, Boolean ignoreCalculationCondition)

              at Touchpaper.Framework.Data.DataObject.ProcessLifecycleTransitionStep(ITransitionStep step, Object param1, Object param2, Boolean validateOnly, IList`1 automaticActionsList)

              at Touchpaper.Framework.Data.DataObject.ProcessLifecycleTransitionStep(ITransitionStep step, Object param1, Object param2, Boolean validateOnly, IList`1 automaticActionsList)

              at Touchpaper.Framework.Data.DataObject.ProcessLifecycleTransition(ITransition transition, Object param1, Object param2, Boolean validateOnly)

              at Touchpaper.Framework.Data.DataObjectContext.ProcessLifecycleAction(DataObject dataObject, IBusinessFunction function, Object param1, Object param2, Boolean isAutomatic, Boolean validateOnly)

              at Touchpaper.Framework.Data.DataObjectContext.ProcessBusinessFunction(FunctionInvocation functionInvocation, Boolean isAutomatic, Boolean validateOnly)

              at Touchpaper.Framework.Data.DataObjectContext.ProcessBusinessFunctions()

              at Touchpaper.Framework.Data.DataObjectContext.SaveChanges()

              at Touchpaper.Web.Console.Controllers.ObjectController.SaveInternal(ObjectParameters parameters, Func`3 getObject)

              at Touchpaper.Web.Console.Controllers.ObjectController.Save()

              at lambda_method(Closure , ControllerBase , Object[] )

              at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)

              at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)

              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.b__33()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.b__36(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.b__20()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.b__22(IAsyncResult asyncResult)

               

              Inner Exception: - Data at the root level is invalid. Line 1, position 1.
              at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
              at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
              at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
              at System.Xml.XmlReader.MoveToContent()
              at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSDataObjectRef.Read14_dor()

              • 4. Re: Unresolve decision based on created by
                elizabethcombrink Employee

                Post your calc - that error usually means that you need to add an extra if statement to exclude the possibility of testing against a null value

                • 5. Re: Unresolve decision based on created by
                  GarethReeves Apprentice

                  I would post it but it will not let me edit it to get to the text?!?!

                  • 6. Re: Unresolve decision based on created by
                    GarethReeves Apprentice

                    Randomly decided to let me edit it....

                     

                    import System

                    static def GetAttributeValue(Incident):

                    Value = false

                     

                    CurrentUser = Incident.GetCurrentUser

                    CurrentUserTitle = Incident.GetObjectByAttribute("System.User","Name",CurrentUser)

                     

                    if Incident.UnResolvesCollection != null:

                         Unresolves = Incident.Unresolves.Latest()

                         if Unresolves.LastUpdatedBy != null:

                               UserType = Unresolves.LastUpdatedBy.UserType.Name     

                     

                    if UserType == "Analyst":

                         Value = true

                    else:

                         Value = false

                         return Value

                    • 7. Re: Unresolve decision based on created by
                      Jamie Cannon ITSMMVPGroup

                      Try this.  I changed it to a .Count and I updated the variable to UnresolveData because I noticed the there was another real attribute that was butting heads potentially.  When you test your calculation against a ticket that has an unresolve, do you get a result of True or False or something else?  Also, make sure the "return" statement at the end lines up with the initial "Value" setting.  It looks like it was under the else: statement (which could just be the copy any paste screwing it up)

                       

                       

                      import System

                      static def GetAttributeValue(Incident):

                      Value = false

                       

                      CurrentUser = Incident.GetCurrentUser

                      CurrentUserTitle = Incident.GetObjectByAttribute("System.User","Name",CurrentUser)

                       

                      if Incident.UnresolvesCollection.Count > 0:

                           UnresolveData = Incident.Unresolves.Latest()

                           if UnresolveData.LastUpdatedBy != null:

                                 UserType = UnresolveData.LastUpdatedBy.UserType.Name     

                       

                      if UserType == "Analyst":

                           Value = true

                      else:

                           Value = false

                       

                      return Value

                      • 8. Re: Unresolve decision based on created by
                        GarethReeves Apprentice

                        I am confused over these Indent errors, cut and paster code exactly as shown, getting;

                         

                        Test(3,1): BCE0044: expecting "INDENT", found 'Value'

                        Test(19,1: BCE004: expecting "DEDENT",found ".

                         

                        how do I line these up? do you have a screenshot of this code in the calculation window so i can compare?

                         

                        Thanks again.

                        • 9. Re: Unresolve decision based on created by
                          Jamie Cannon ITSMMVPGroup

                           

                          I tried adding the actual code so you could copy it but it kept putting it on one line.  Hope this helps.

                          • 10. Re: Unresolve decision based on created by
                            GarethReeves Apprentice

                            getting this now, when testing!

                             

                            error.png

                            • 11. Re: Unresolve decision based on created by
                              GarethReeves Apprentice

                              Matches the layout as far as I can see. This seems unnecessarily difficult!

                              latest_error.png

                              • 12. Re: Unresolve decision based on created by
                                Jamie Cannon ITSMMVPGroup
                                import System
                                static def GetAttributeValue(Incident):
                                
                                    Value = false
                                
                                    CurrentUser = Incident.GetCurrentUserName()
                                    CurrentUserTitle = Incident.GetObjectByAttribute("System.User","Name",CurrentUser)
                                
                                    if Incident.UnresolvesCollection.Count > 0:
                                
                                        UnresolveData = Incident.Unresolves.Latest()
                                
                                        if UnresolveData.LastUpdatedBy != null:
                                
                                            UserType = UnresolveData.LastUpdatedBy.UserType.Name     
                                
                                    if UserType == "Analyst":
                                
                                        Value = true
                                
                                    else:
                                
                                        Value = false
                                
                                    return Value
                                
                                • 13. Re: Unresolve decision based on created by
                                  Jamie Cannon ITSMMVPGroup
                                  import System  
                                  static def GetAttributeValue(Incident):  
                                    
                                      Value = false  
                                    
                                      CurrentUser = Incident.GetCurrentUserName()  
                                      CurrentUserTitle = Incident.GetObjectByAttribute("System.User","Name",CurrentUser)  
                                    
                                      if Incident.UnResolves.Count > 0:  
                                    
                                          UnresolveData = Incident.UnResolves.Latest()  
                                    
                                          if UnresolveData.LastUpdateUser != null:  
                                    
                                              UserType = UnresolveData.LastUpdateUser.UserType.Title       
                                    
                                      if UserType == "Analyst":  
                                    
                                          Value = true  
                                    
                                      else:  
                                    
                                          Value = false
                                      
                                      return Value
                                  

                                   

                                  In front of my machine now.  This would be using the OOTB attributes.

                                  • 14. Re: Unresolve decision based on created by
                                    GarethReeves Apprentice

                                    Last one then i'm giving up.

                                    another_error.png

                                    1 2 Previous Next