Finding Common Members Between Two Groups in Subflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @saint ,
Since you have users from both groups, you just need to find the common ones between the two lists.
Add a Script step in your subflow and use logic like this:
var commonUsers = [];
for (var i = 0; i < inputs.group1_users.length; i++) {
if (inputs.group2_users.indexOf(inputs.group1_users[i]) > -1) {
commonUsers.push(inputs.group1_users[i]);
}
}
outputs.common_users = commonUsers;
Takes users from Group 1, Checks if they also exist in Group 2
If yes → adds them to output, So you’ll get only common members
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @saint
Add a Script Step to evaluate the overlap and set up the following inputs and outputs:
Inputs:
- group_a_users: Map this to the sys_id list from your first Look Up Records.
- group_b_users: Map this to the sys_id list from your second Look Up Records.
Output:
- Name: common_users
- Type: String (or Array.String depending on subflow requirements)
Sample code/Not tested:
(function execute(inputs, outputs) {
var arrA = inputs.groupA ? inputs.groupA.split(',') : [];
var arrB = inputs.groupB ? inputs.groupB.split(',') : [];
var arrayUtil = new global.ArrayUtil();
var common = arrayUtil.intersect(arrA, arrB);
outputs.common_users = common.join(',');
})(inputs, outputs);
You can then map this output variable directly to your subflow’s output field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi Saint,
You can try this:
Convert group members into sys_id lists → compare them in a Script step → return the common users as a subflow output.
Step 1: Get users from both groups (Main Flow)
1. Use Lookup Records
Table: sys_user_grmember
--> Condition:
group = <Group Abc>
2. From the results, collect:
-user.sys_id
3. Convert the result into a comma‑separated string
Example:
sysid1,sysid2,sysid3
Repeat the same steps for Group B.
Step 2: Create a Subflow
Create a subflow as XXX
Create subflow inputs:
Name Type
group1_users --> String
group2_users --> String
These inputs should contain comma‑separated user sys_ids from each group.
Step 3: Add a Script step inside the Subflow
Add an Action → Script step and use the following logic:
Script :
(function execute(inputs, outputs) {
var group1 = inputs.group1_users.split(',');
var group2 = inputs.group2_users.split(',');
var commonUsers = [];
for (var i = 0; i < group1.length; i++) {
if (group2.indexOf(group1[i]) > -1) {
commonUsers.push(group1[i]);
}
}
outputs.common_users = commonUsers.join(',');
})(inputs, outputs);
Step 4: Define Subflow Output
Create one output:
Name Type
common_users --> String
This output will contain the sys_ids of users present in both groups.
Hope this helps! If it answers your question, please consider marking it as Helpful or accepting it as a solution.
Thank you!
