haseena ayesha
Giga Guru

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!