Skip to content

Commit 4c17544

Browse files
authored
Get active mid servers (#877)
* Create GetActiveMidServer.js Retrieves the name of an active MID Server that is both up and validated. * Create readme.md Readme file for Script to get active MID server
1 parent 09ffe07 commit 4c17544

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Retrieves the name of an active MID Server that is both up and validated.
3+
* @returns {string|null} The name of the active MID Server, or null if none is found.
4+
*/
5+
function getActiveMidServer() {
6+
// Create a GlideRecord object for the 'ecc_agent' table
7+
var grServer = new GlideRecord('ecc_agent');
8+
9+
// Add an encoded query to filter for MID Servers that are up and validated
10+
grServer.addEncodedQuery('status=Up^validated=true');
11+
12+
// Execute the query
13+
grServer.query();
14+
15+
// Check if a record matching the query criteria was found
16+
if (grServer.next()) {
17+
// Return the name of the active MID Server
18+
return grServer.name;
19+
} else {
20+
// No active MID Server found, return null
21+
return null;
22+
}
23+
}
24+
25+
getActiveMidServer();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ServiceNow Script: getActiveMidServer
2+
3+
## Description
4+
This ServiceNow script defines a function, `getActiveMidServer`, that retrieves the name of an active MID Server that is both up and validated. MID Servers are essential components in the ServiceNow platform for various integration and automation tasks.

0 commit comments

Comments
 (0)