1 Reply Latest reply on Sep 20, 2016 11:36 AM by wamccoid

    Precondition for approval on a process

    DrNelson Apprentice

      We have a lot of processes in service desk that require approval/ rejection. The people that approve/ reject these requests are not always a set group of people (due to many factors), so it would not be feasible to add them to a role or group. Would it be possible to add a precondition before any authorize/ reject action that checks to see if a user is a member of the current group or role that the notification was sent to? Example a user submits a form and lists their approving manager, they in turn get a notification telling them that there is a request that needs their approval/ rejection. The manager logs into service desk and approves or rejects the request. What I am trying to avoid is the end user going in and approving their own request.

        • 1. Re: Precondition for approval on a process
          wamccoid Specialist

          This is totally possible.  Here are a couple calcs you could combine to do this.  You will have to create a precondition and then use a calculation in the precondition.  You will have to modify the Calcs below and change Request to whichever module you are writing it for.

           

          This calculation looks the current user is a member the assigned group or is the assigned user.

          import System 

          static def GetAttributeValue(Request): 

            Value = false

            AssignGroup ='No Assignment' 

            UserText = 'SA' 

            UserText = Request.GetCurrentUserName()

            UserObject = Request.GetObjectByAttribute("System.User", "Name", UserText)

            if Request.Status.IsEnd == false and Request.Status.IsCompletion == false:

            if Request.Assignments.Count > 0:

            if Request.Assignments.Latest().User != null:

            if Request.Assignments.Latest().User.Name.ToLower() == Request.GetCurrentUserName().ToLower():

            Value = true

           

            if Request.RaiseUser.Name != UserText:

            for item in UserObject.UserGroups:

            if item.Group.Title == Request.Assignments.Latest().Group.Title:

            Value = true

            return Value

           

          This calculation looks to see if the user is a member of a specific role.

           

          import System 

          static def GetAttributeValue(Incident): 

            Value = false 

            AssignGroup ='No Assignment' 

            UserText = 'SA' 

           

            UserText = Request.GetCurrentUserName()

            UserObject = Request.GetObjectByAttribute("System.User", "Name", UserText)

           

            for item in UserObject.UserRoles:

            if item.Role.Title == 'TrainingManager':

            Value = true

            return Value

          Hope all this helps.

          Regards,

          Will McCoid | Lead ITSM Consultant | Network Consulting Services INC | www.ncsi.us