This article details the steps necessary to filter an application in Semarchy xDM based on the roles of the connected user. While the core components of this solution can be applied to multiple scenarios, this article focuses on filtering Business Views.

The provided example uses the CustomerB2C demo application: the objective is to filter products depending on their origin and the regional roles (e.g ""Data Steward USA", "Data Steward Asia"...) owned by the connected user.

Solution overview

This solution is based on:

  • The USER_ROLES built-in SemQL variable: this variable provides the list of roles of the connected user
  • The custom SemQL function SEM_F_SPLIT (only available for Oracle and Postgres).SEM_F_SPLIT is a database-level function created by the Semarchy dev team, and is deployed automatically during platform configuration. Although not visible through the xDM application, it can be found under Functions in either Oracle or Postgres. string_split is the Microsoft SQL Server equivalent function.

Understanding how to apply these elements will help determine what conditions they'll be best suited for.

Step 1 - Configure groups and roles

Our example uses Active Directory, so users must first be properly configured beforehand. Users must first be part of AD groups and the group be configured under Roles and have Model Privileges in order for the scenario to work properly.

Step 2 - Set up the filter on the Business View

Navigate to the Entity > open the related Business View > edit expression for Root Filter.

Since we want to change views based on the Origin attribute in the Product entity, we include this attribute as part of the clause. Additionally, we specify the values for the Roles we declared earlier, as well as the values (Countries) for each condition.

Origin in SEM_F_SPLIT(
  when :V_USER_ROLES like '%DataStewardAsia%' then 'China, Japan'
  when :V_USER_ROLES like '%DataStewardUSA%' then 'USA'
  end, ','

Step 3 - Deploy and test

After applying the filter containing the SemQL function SEM_F_SPLIT, save changes, validate the model, and refresh the application. Connecting to the application as DataStewardUSA-User should result in a filtered Business View that only shows members with an Origin of USA.

Business view connected as DataStewardUSA-User