Filtering the Data Shown in a Report Based on the Logged in User's Team Membership

The Process Monitor dashboard demonstrates how you can use ActiveMatrix BPM web services to obtain organizational information about the dashboard user (in this case, whether they are a team leader, and of which team), and so restrict the data presented to that user based on their team membership and role.

In the example Claims application, the organization model provides a simplistic model of EasyAs Insurance's claims processing organization, comprising a front desk team and a back desk team, each with a manager:

In TIBCO Business Studio:

  • The front desk team, back desk team and managers are each modeled as a Group.
  • a TeamName resource attribute is added to the CompanyOrganizationModel project.

At runtime (see Mapping Users from the EasyAs LDAP Source to the Claims Organization Model):

  • The following resources are mapped to each group.
    Group Resources
    Team Managers Leon Court, Richard Cresswell
    FrontDeskGroup Richard Cresswell, John Eustace, Liam Lawrence, Tony Pulis
    BackDeskGroup Leon Court, Clint Hill, Jon Parkin, Steve Simonsen
  • The team managers have the following values assigned to their TeamName resource attribute. (Other team members do not have a TeamName value assigned.)
    Resource Value of TeamName resource attribute
    Leon Court BackDeskGroup
    Richard Cresswell FrontDeskGroup

When the Process Monitor dashboard (jaspershowcase.html) is opened in Openspace, the onReportLoaded function calls getTeam (in Jaspershowcase.java).

function onReportLoaded() {
  // This method will be called when the GWT onModuleLoad has run so we 
  // know at this point that it will have exported any methods we may 
  // need.

  // Now call into GWT Layer to trigger it to go and work out the team.  
  // Because this is async it will not return it here, but rather will 
  // call a method later to set it.
  // We pass in a callback function which we would like to be called when 
  // this operation is complete
  getTeam(setMyTeam);
}
  1. getTeam calls the BPM Web Client API GetAuthenticatedUserName operation to find the name of the logged in user.
  2. getTeam now needs to look up the value of that user's TeamName attribute. However, this cannot be done directly from the BPM Web Client API, so it calls getMyResourceAttribute, which is a JSNI method that in turn invokes the callGetResource function in osApi.js.
  3. callGetResource uses the following BPM REST API calls to obtain the value of the user's TeamName attribute, which it then passes back to the setResourceAttribute function (in Jaspershowcase.java):
    1. findResources - passing in the user's name and extracting the user's GUID from the returned data.
    2. getResource - passing in the user's GUID and extracting the TeamName resource attribute value.
  4. setResourceAttribute:
    1. calls the BPM Web Client API RunResourceQueryForVersion operation to get the names of the users who are members of the group named in the TeamName resource attribute value.
    2. calls the doCallback function, which passes the list of team members back to the setMyTeam function in jaspershowcase.htm.
      Note: If the logged in user is not one of the team leaders (so the list of team members is empty), doCallback instead displays the error message This user is not a manager of a team, cannot display dashboard.
  5. setMyTeam initializes required variables with the team information and updates the context object.
    function setMyTeam(teamname, teamnames) {
      teamName = teamname;
      myTeam = teamnames;
      updateContext();
      setTeamMode(true);
      //Now we initialise Visualise.js
      initVisualise(init);
    }
    Note: The dashboard does not initialize Visualize.js (and consequently the reports) until it has the required context and team information.

The team information can now be passed as a parameter (via context.team) to the various reports when they are called or updated. Each report can use the team information as required to filter, construct and/or display the required data.