Use script includes to suppress filters and breadcrumbs

You can use a script to restrict filters and breadcrumbs to specific roles, either on a per-table or global basis. Using a script is an advanced option that offers additional flexibility compared to using list control.

Before you begin

Using a script include requires knowledge of JavaScript.

Role required: script_include_admin

Procedure

  1. Create a script include with the name <tablename>DisplayFilter.
    The script section contains one function with the same name as the script include.
  2. Use your function to set the global variable answer to either true (show the filters and breadcrumbs) or false (hide them.)
    The following example restricts filters and breadcrumbs on the Incident table to users with any role. Be sure that the name of the script matches the function name exactly, including case.
    var incidentDisplayFilter = Class.create();
    
    incidentDisplayFilter.prototype = {
        type: 'incidentDisplayFilter',
    
        initialize: function() {
        },
    
        incidentDisplayFilter: function() {
            var answer;
    
            if (gs.hasRole()) {
                answer = true;
            } else {
                answer = false;
            }
    
            return answer;
        }
    };
  3. (Optional) To exclude a specific role from having access to filters and breadcrumbs, make the following change.
    var incidentDisplayFilter = Class.create();
    
    incidentDisplayFilter.prototype = {
        type: 'incidentDisplayFilter',
    
        initialize: function() {
        },
    
        incidentDisplayFilter: function() {
            var answer;
    
            if (gs.hasRole() && !gs.hasRole('newrole')) {
                answer = true;
            } else {
                answer = false;
            }
    
            return answer;
        }
    };

    Users with the role newRole do not have access to filters and breadcrumbs.

  4. (Optional) To let all users use filters and breadcrumbs on the Incident table, make the following change to your script.
    var incidentDisplayFilter = Class.create();
    
    incidentDisplayFilter.prototype = {
        type: 'incidentDisplayFilter',
    
        initialize: function() {
        },
    
        incidentDisplayFilter: function() {
            var answer = true;
    
            return answer;
        },
    };
  5. (Optional) To modify filter and breadcrumb access for another table, create a script include using the name of that table instead of Incident.