<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content

How to Add Users to Multiple Groups Based on Department Using Okta Workflows

Okta Classic Engine
Okta Identity Engine
Workflows

Okta Workflows can automatically add users to multiple groups based on their department by referencing a table that maps departments to groups. The department-to-group mapping is stored in a Workflows table with two columns — department and group — where a single department can have multiple rows, one for each group its users should belong to. Updating group assignments requires only editing the table, leaving all flows unchanged.

 

 

Automation Flow Architecture

The solution uses three flows that work together to look up each active user's department, find all associated groups, and add the user to each one.

Department groups table example

The Department groups table maps each department to one or more Okta groups.

 

The three flows are:

  1. List users — lists active users and streams each one to the List groups flow.
  2. List groups — looks up the user's department in the table and returns all groups associated with it.
  3. Add to group — finds the group by name and adds the user to it.

 

 

The List Users Flow

The List users flow lists all active Okta users and passes each user to a helper flow.

List users flow example

The List users flow streams active users to the List groups helper flow.

 

How Does the List Users Flow Work?

The Okta-List Users with Search card lists users with the Active status using the streaming option, passing each user to the List groups helper flow.

 

 

The List Groups Flow

The List groups flow finds the groups for the user's department in the table and calls a helper flow for each group.

List groups flow example

The List groups flow searches the table by department and loops through the matching rows.

 

List Groups Flow Steps

Set up the Helper Flow input fields, search the Department groups table, and iterate through the results to call the Add to group helper flow for each matching row by following these steps:

 

  1. The Helper Flow sets up the Record and State fields because the main flow uses streaming. The Record field contains the user's data. The flow extracts the user ID and the department directly from the Record object.
  2. The Table-Search Rows card searches the Department groups table for all rows where the department column equals the user's department.
  3. The List-For Each card iterates through the matching rows and calls the Add to group helper flow for each row, passing the group name and user ID.

 

 

The Add to Group Flow

The Add to group flow finds a group by name and adds the user to it.

Add to group flow example

The Add to group flow searches for the group and adds the user to it.

 

How Does the Add to Group Flow Work?

The flow receives the group name and user ID from the List groups flow, searches for the group, and adds the user to it using the following steps:

  1. The Helper Flow receives the Group name and User ID from the List groups flow.
  2. The Okta-Search Groups card searches for the group by name and returns the ID of the first matching group.
  3. The Okta-Add User to Group card adds the user to the group using the group ID and user ID.

 

 

Related References

Loading
How to Add Users to Multiple Groups Based on Department Using Okta Workflows | Okta Support