Skip to content

Commit f0b4256

Browse files
authored
Merge branch 'main' into email_number_validate
2 parents 6ec1f97 + 2d94cb3 commit f0b4256

10 files changed

+32787
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
M0FlXWLl0mO2tJkh-decdUtx_XAh3_vGmhWYyvDOQ-yzEXYZqbzEReAXiPZclHAd81yJ1KOHQkWcK0krxPd00zr9Ki7_u1rdb8X-ktHb5a1VVMfNeAMpD-Q1vOOTEUBeyyIso8Dseti9s7AAxQP6OvGsvYysv88wyw49roqBreTJFRgRKFZtP7Nlw7B35pBHC1VguVuCMK6TMGkQNv9wCif-R93jIAvVc3-XZhlUYkrbDQQnsaqnfem6A9wFeQB6ilgUbkJ_WdOiQIORheBwjfVTgRu1WRltPg_mrvOYSgGqlStmrWEFGKodZYhzD0PvPzCC93JVC1v53KfNQzsqM4ST6XmT8s8dFLwXfUv27pByf6RryFqWzGL848rTNQwYulPxAaVqtwWiweX86PVoTMrlHlL0jM2rH2cKGynUWnRWN4A6HfTZUzEdu1uVTIGtp-oVwasHIMAtO-JaulAk4xhDov078LsXvT4VnIUwTyHeLN79HUdKR99p270VDC5Cm1fKdFjqz41b6ER8umXsgajHG658OgFppK2md4CxJWqqUav7PLdYnKiuSAI3tGb9aE1fBum6lnhYqwjCyA2iuqlqTzr0-g6z51SjRyD0MmPiqiTyWdUOSIdkwlox5VLJGT8AYwDaEryccWaspDAphNIgK0raMg1dHaCNyE_N2Ds
1+
M0FlXWLl0mO2tJkh-decdUtx_XAh3_vGmhWYyvDOQ-yzEXYZqbzEReAXiPZclHAd81yJ1KOHQkWcK0krxPd00zr9Ki7_u1rdb8X-ktHb5a1VVMfNeAMpD-Q1vOOTEUBeyyIso8Dseti9s7AAxQP6OvGsvYysv88wyw49roqBreTJFRgRKFZtP7Nlw7B35pBHC1VguVuCMK6TMGkQNv9wCif-R93jIAvVc3-XZhlUYkrbDQQnsaqnfem6A9wFeQB6ilgUbkJ_WdOiQIORheBwjfVTgRu1WRltPg_mrvOYSgGqlStmrWEFGKodZYhzD0PvPzCC93JVC1v53KfNQzsqM4ST6XmT8s8dFLwXfUv27pByf6RryFqWzGL848rTNQwYulPxAaVqtwWiweX86PVoTMrlHlL0jM2rH2cKGynUWnRWN4A6HfTZUzEdu1uVTIGtp-oVwasHIMAtO-JaulAk4xhDov078LsXvT4VnIUwTyHeLN79HUdKR99p270VDC5Cm1fKdFjqz41b6ER8umXsgajHG658OgFppK2md4CxJWqqUav7PLdYnKiuSAI3tGb9aE1fBum6lnhYqwjCyA2iuqlqTzr0-g6z51SjRyD0MmPiqiTyWdUOSIdkwlox5VLJGT8AYwDaEryccWaspDAphNIgK0raMg1dHaCNyE_N2Ds

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_0571601447a872108633e99b116d43bc.xml

Lines changed: 3255 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_1b1992103ba83250b61f3c8c24e45a8f.xml

Lines changed: 8061 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_2ff2892cc328f2104e08bd43e40131bc.xml

Lines changed: 2825 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_57b0f414c3a0b2104e08bd43e40131c2.xml

Lines changed: 3687 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_819c78a083ec7210086cb5a6feaad30b.xml

Lines changed: 2377 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_b5b3699c832c3210086cb5a6feaad36e.xml

Lines changed: 2691 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_c8da5bc4c364be10d9d679ec05013162.xml

Lines changed: 4759 additions & 0 deletions
Large diffs are not rendered by default.

b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_f8bcf8d0c3acbe10d9d679ec050131fd.xml

Lines changed: 5009 additions & 0 deletions
Large diffs are not rendered by default.

who_is_on_call/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
README — Get Current On-Call Users (Flow Action)
2+
Purpose:
3+
This Flow Designer Custom Action retrieves the current on-call user(s) for a specified assignment group in ServiceNow using the On-Call Scheduling API.
4+
It can be used in Flows or Subflows to automatically assign incidents, notify escalation contacts, or integrate with messaging systems (Slack, Twilio, etc.).
5+
6+
<img width="1917" height="944" alt="image" src="https://github.com/user-attachments/assets/bbe7fe6a-7418-4c28-9f77-d03dbf64417f" />
7+
8+
9+
🧭 Overview
10+
11+
When triggered, this action:
12+
13+
Looks up the current date/time or a specified timestamp.
14+
15+
Calls global.OnCallRotation().whoIsOnCall() to determine who’s on-call.
16+
17+
Returns a JSON list of all active on-call members (Primary, Secondary, etc.).
18+
19+
Exposes the first on-call member separately for easy assignment or alerting.
20+
21+
⚙️ Inputs
22+
Name Type Required Description
23+
group_sys_id String ✅ Yes The sys_id of the target sys_user_group (e.g., “Major Incident Managers”).
24+
when Date/Time No Optional — specific time to check coverage. Defaults to current time.
25+
📤 Outputs
26+
Name Type Description
27+
users_json String JSON array of on-call user details (sys_id, name, email, phone).
28+
count Integer Total number of users found in the on-call list.
29+
first_user_sys_id String Sys ID of the primary on-call user.
30+
first_user_name String Name of the primary on-call user.
31+
first_user_email String Email address of the primary on-call user.
32+
first_user_phone String Phone number of the primary on-call user.
33+
🧠 Script Logic (Core)
34+
(function execute(inputs, outputs) {
35+
if (!inputs.group_sys_id) {
36+
throw new Error('group_sys_id is required');
37+
}
38+
39+
var rota = new global.OnCallRotation();
40+
var gdt = inputs.when ? new GlideDateTime(inputs.when) : new GlideDateTime();
41+
var list = rota.whoIsOnCall(inputs.group_sys_id + '', '', '', gdt);
42+
43+
var users = [];
44+
if (list && list.length && list.length > 0) {
45+
for (var i = 0; i < list.length; i++) {
46+
var member = list[i];
47+
var userSysId = member.userSysId || member.userId;
48+
49+
if (userSysId) {
50+
var userGR = new GlideRecord('sys_user');
51+
if (userGR.get(userSysId)) {
52+
users.push({
53+
order: i,
54+
sys_id: userGR.getUniqueValue(),
55+
name: userGR.getDisplayValue(),
56+
email: (userGR.email || '').toString(),
57+
phone: (userGR.mobile_phone || userGR.phone || '').toString()
58+
});
59+
}
60+
}
61+
}
62+
}
63+
64+
outputs.users_json = JSON.stringify(users);
65+
outputs.count = users.length;
66+
67+
outputs.first_user_sys_id = users[0] ? users[0].sys_id : '';
68+
outputs.first_user_name = users[0] ? users[0].name : '';
69+
outputs.first_user_email = users[0] ? users[0].email : '';
70+
outputs.first_user_phone = users[0] ? users[0].phone : '';
71+
72+
})(inputs, outputs);
73+
74+
🧩 Usage Example
75+
76+
Flow: “Auto-Assign Major Incident to On-Call Manager”
77+
78+
Trigger: Major Incident Created
79+
80+
Action: Get Current On-Call Users
81+
82+
group_sys_id = e3abf0a8db20b2000ea6fb37bf961969
83+
84+
Condition: count > 0
85+
86+
Set field: Assigned to = ${first_user_sys_id}
87+
88+
Send notification: “Paging ${first_user_name} (on call)”
89+
90+
Else: Fallback to queue or send escalation email.
91+
92+
🧱 Dependencies
93+
94+
Plugin: On-Call Scheduling (com.snc.on_call_rotation)
95+
96+
Tables Accessed:
97+
98+
sys_user
99+
100+
cmn_rota (via API call)
101+
102+
Roles:
103+
104+
admin or any role with read access to On-Call tables.
105+
106+
🧩 Testing
107+
Scenario Expected Result
108+
Group has active on-call rotation Returns 1+ users in users_json
109+
Group has no rotation Returns count = 0
110+
Future when value Returns users scheduled at that time
111+
Invalid group_sys_id Script throws error message
112+
⚠️ Notes & Gotchas
113+
114+
Use global.OnCallRotation(), not SNC.OnCallRotation(), for global scope.
115+
116+
The whoIsOnCall() API returns a JavaScript array, not a GlideRecord list.
117+
118+
The first returned user (index 0) is treated as Primary; subsequent ones are Secondary/Backup.
119+
120+
Ensure on-call rosters are configured with valid coverage windows and active users.
121+
122+
If you want to include future shifts, modify the script to iterate over days with addDaysUTC().

0 commit comments

Comments
 (0)