How To: Show/Hide an action from a specific role with a calculated pre-condition

Version 6

    Verified Product Versions

    LANDESK Service Desk 7.6LANDESK Service Desk 7.7.xLANDESK Service Desk 7.8.xLANDESK Service Desk 2016.xLANDESK Asset Central 2016.x

    Environment:

    Service Desk 7.3 and above

     

    Requires Access To:

    Console

     

    How To:

    In this article, we are going to describe how to show or hide actions for a specific role without modifying the privileges. Indeed, sometimes it is required to hide an action at a specific status only (like Add Notes) and we are going to apply this example on an incident process.

     

    Step by Step:

    In this example, let's work on a simple process which contains two statuses "Open" and "Closed", and an action "Add Notes" that we want to be visible only by users having the administrator role. Add a precondition before this action "Add Notes" and call is "Is Admin" for instance as on the screenshot below:

    1) Process Example.png

    Set up this precondition as the following: Condition Type = Calculation, Condition = Equal, Value = true. Then use the following calculation and adapt it to the context of your environment:

     

    import System
    static def GetAttributeValue(Incident):
      Value = false
      Username = Incident.GetCurrentUserName().ToLower()
      User = Incident.GetObjectByAttribute("System.User", "Name", Username)
      for item in User.UserRoles:
           if item.Role.Name == 'Administrators':
                Value = true
      return Value
    

     

    As mentioned above, this is a specific example and you must replace 'Administrators' by the name of another role ('Analyst' for instance). Use the name which is unique, not the title !

    This calculation is called from an Incident process but can of course be applied to any other process

    You can of course adapt this calculation to Groups instead of Roles

     

    Result:

    We created two users for this example, one Analyst and one Administrator. We expect then the administrator to see this "Add Note" action while the analyst doesn't.

    2) Comparison Analyst vs Admin.png

    Related links:

    Ivanti Service Desk Calculations Landing Page

    Calculation Writing Tutorial - 2. Variables and Conditional Logic ("if" statements)

    Calculation Writing Tutorial - 4.  Working with Collections and Loops

    Best Known Method: Working with Preconditions and automatic actions