Checking for down MID servers, and current open incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 01:07 AM
Hey guys, wondered if anyone could help me with this code I'm working on. I have a flow which fires when a MID state is down and will execute a workflow, the workflow goes through a few checks and ultimately raises a ticket. I know the mid name is in the scratchpad and working,
There is an open incident with this MID name currently and matches this criteria. If I run this code in background scripts and replace the return with gs.info and replace the MID name, I can get a yes/no returned. So I know this works, just seems to fall over inside a workflow and its baffling me! Any help would be really appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 02:41 AM
To check for down MID servers and current open incidents in ServiceNow, you can follow these steps:
1. **Checking for Down MID Servers:**
- Navigate to "MID Server" > "Servers".
- The list of MID servers will be displayed.
- Check the "Status" column for each MID server. If the status is "Down", then the MID server is not running.
2. **Checking for Current Open Incidents:**
- Navigate to "Incident" > "Open".
- The list of open incidents will be displayed.
- You can further filter this list based on assignment group, priority, etc.
Please note that you need the appropriate roles to view these modules and lists.
For automating these checks, you can use ServiceNow scripting. Here is a basic example of how you can do it:
javascript
// Checking for down MID servers
var midServer = new GlideRecord('ecc_agent');
midServer.addQuery('status', 'Down');
midServer.query();
while(midServer.next()) {
gs.print('MID Server ' + midServer.name + ' is down.');
}
// Checking for open incidents
var incident = new GlideRecord('incident');
incident.addQuery('state', '!=', 6); // 6 is the state value for "Closed"
incident.query();
while(incident.next()) {
gs.print('Incident ' + incident.number + ' is open.');
}
This script will print the names of down MID servers and open incidents to the system log. You can modify it to send notifications, create incidents, etc., based on your needs.
nowKB.com
For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 02:48 AM
Hi Ahana, thank you for the reply.
I dont need to print the incident number, just a simple count to see if any open records meet my criteria. The plan is to terminate the workflow if an incident is open to avoid duplication. However the If statement in the workflow always ends up at the 'no' condition, despite there being open records that match this criteria.
Running the same script in background scripts (with a modified MID name) returns yes.