You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flow Action: inputs of a List of SysID's and it creates a Shuffled Arrays, Matches of 2 sysIDs
1
+
# Random Pair Generator
2
+
3
+
## Overview
4
+
This script generates random pairs from an input array.
5
+
It is useful for creating **tournament matches**, **group assignments**, or **randomized pairings**.
6
+
7
+
The script is structured to run in a scoped execution context (such as **ServiceNow Flow Designer Actions** or **Scripted REST Transforms**) where it accepts `inputs` and `outputs` objects.
8
+
9
+
---
10
+
11
+
## How It Works
12
+
1.**Shuffle the Input Array**
13
+
- Implements the Fisher–Yates algorithm in `shuffleArray()` to randomize the array.
14
+
15
+
2.**Create Random Pairs**
16
+
- Iterates through the shuffled array in steps of two.
17
+
- Forms pairs `[item1, item2]`.
18
+
- If the array has an odd length, the last item is placed in a single-element array `[item]`.
19
+
20
+
3.**Return Results**
21
+
- The final set of pairs is returned as `outputs.match`.
0 commit comments