Switch Tenant

The Switch Tenant component allows users to select one of their associated tenants during a flow. Once selected, tenant details can be used in conditions, logic branches, or displayed on screen. This guide explains how to use the component, access selected tenant data, and dynamically update tenant information within a flow.

The Component

Note

Tenants will automatically be sorted in alphabetical order.

Create a new screen inside a flow, and search for "Switch Tenant":

Switch tenant component in Descope screen

This component allows a user to choose from the list of tenants they are associated with. Once selected, the tenant's details are available for use in the flow.

Implementing Tenant Selection In Descope Flows

Flow Overview

The example below shows a flow where a user selects a tenant. The flow then evaluates the selected tenant’s name using a condition.

  • If the tenant name is "test", the flow ends.
  • Otherwise, the tenant's SSO configuration is shown.

Descope flow using tenant name through switch tenant component

A Closer Look At The Condition

Here is a closer look at the condition that uses the tenant's name:

A condition based on tenant details in Descope

You can also use the tenant's domain(s) and any custom attributes you define. For creating custom attributes, you can read further here.

Using The Selected Tenant Form Value

After the user selects a tenant in the flow, it can be accessed from the form context as {{form.userSelectedTenant}}.

JWT After Tenant Selection

After the tenant has been selected, the JWT will have the dct (descope current tenant) claim marking which tenant is the actively selected tenant. If there's just one tenant associated with the user, the tenant does not have to be selected because the dct is automatically set to that one tenant.

{
  "amr": [
    "oauth"
  ],
  "dct": "T2JEfswIPhl9I5YipLhSLNa6VfVV",
  "drn": "DS",
  "exp": 1708620768,
  "iat": 1708620588,
  "iss": "xxxxx",
  "rexp": "2024-03-21T16:49:48Z",
  "sub": "xxxxx",
  "tenants": {
    "xxx": {},
    "T2JEfswIPhl9I5YipLhSLNa6VfVV": {},
    "xxx": {},
  }
}
Was this helpful?

On this page