3 Replies Latest reply on Jul 11, 2018 8:05 PM by abuzaki92

    Precondition causing error in WebAccess

    abuzaki92 Rookie

      Hi,

       

      I'm seeing error in WebAccess ticket where it was caused by a precondition.

       

      2.PNG

      As you can see in the process above, the status "Task In Progress" is connected to the precondition "Current Assigned Group is Within Group".

      I think it's causing the following error when analyst/user trying to view the task ticket with the "Task In Progress" status.

      3.PNG

       

      So when I remove the linkage from status to the precondition, finally user can view the task ticket.(as per image below)

      1.PNG

      4.PNG(no error)

       

      Here's the precondition calculation which I think has no problem because the same precondition is used somewhere else without any error.

       

      import System

      static def GetAttributeValue(Task):

           Value = false

           Username = Task.GetCurrentUserName().ToLower()

           User = Task.GetObjectByAttribute("System.User","Name",Username)

            for item in User.UserGroups:

                     if item.Group.Name == Task.CurrentAssignment.Group.Title:

                          Value = true

                          return Value

       

       

      What do you think caused the precondition to be the problem? I can't simply solve this by removing the precondition due to security reasons. The precondition is very much needed.

      Thanks.

        • 1. Re: Precondition causing error in WebAccess
          Julian Wigman ITSMMVPGroup

          abuzaki92 You cant always assume that GROUP holds a value as you can assign to just a user or role or combinations thereof.

           

          The “...(1,1)....” error is usually caused by nulls in a calc IMHO.

           

          So after your FOR line, add this line

           

          if Task.CurrentAssignment != null and Task.CurrentAssignment.Group != null:

           

          Nest your other IF line and pay.iad inside this IF statement above.

           

          The other possible reason is that your “return value” line seems indented; it should start in the same column as the “Value = false” line.

           

          Julian

          MarXtar Ltd

          • 2. Re: Precondition causing error in WebAccess
            Julian Wigman ITSMMVPGroup

            Actually you improve on that and also simplify to this if you want and possibly cater for null checking on your user object ie

             

            import System

            static def GetAttributeValue(Task):

                 Username = Task.GetCurrentUserName().ToLower()

                 User = Task.GetObjectByAttribute("System.User","Name",Username)

                 if User != null and Task.CurrentAssignment != null and Task.CurrentAssignment.Group != null:

                      for item in User.UserGroups:

                               if item.Group.Name == Task.CurrentAssignment.Group.Title:

                                      return true

                 return false

             

             

            Julian

            MarXtar Ltd

            1 of 1 people found this helpful
            • 3. Re: Precondition causing error in WebAccess
              abuzaki92 Rookie

              Hi Julian,

               

              That really helps. Thanks for the explanation.