- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2025 03:25 AM
Hi everyone,
i have write code inside the custom action script but it is showing error :
"Encountered undeclared output variable: platformAdminGroup"
and "Encountered undeclared output variable: uniqueActiveManagers."
Below is the code: In below code Im traying to to achieve all active unique manager associated to group and "platform_admin" group but getting above error but in background script getting expected error.
output of custom action execution in FD:
so how to set the output variable for above requirement can anyone please suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2025 10:40 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2025 03:58 AM
Hi @rmaroti
You need to update the output variable names. Try the below one.
(function execute(inputs, outputs) {
var activeManagers = [];
// Initialize variable to store the platform_admin group record
var platformAdminGroup;
// Query the sys_user_group table to find the group with the name 'platform_admin'
var groupGR = new GlideRecord('sys_user_group');
groupGR.addQuery('name', 'platform_admin'); // Or use sys_id if preferred
groupGR.query();
if (groupGR.next()) {
platformAdminGroup = groupGR.getUniqueValue(); // Store the sys_id of the platform_admin group
}
// Query all active groups from the sys_user_group table
var activeGroupGR = new GlideAggregate('sys_user_group');
activeGroupGR.addQuery('active', true); // Only active groups
activeGroupGR.groupBy('manager');
activeGroupGR.query();
// Iterate through the active groups to find unique active managers
while (activeGroupGR.next()) {
var managerId = activeGroupGR.getValue('manager'); // Get the manager's sys_id
if (managerId && !activeManagers.includes(managerId)) {
activeManagers.push(managerId);
}
}
// Set outputs
outputs.activemanagers = activeManagers;// Return the list of unique active manager sys_ids
outputs.platformadmingroup = platformAdminGroup;// Return the sys_id of the platform_admin group
})(inputs, outputs);
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2025 04:53 AM
you should use the exact output variable names as present in your script step
update these 2 lines with bold as correct output variable names
outputs.activemanagers= activeManagers; // Return the list of unique active manager sys_ids
outputs.platformadmingroup = platformAdminGroup; // Return the sys_id of the platform_admin group
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2025 12:35 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 05:23 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader