0% found this document useful (0 votes)
78 views35 pages

ServiceNow Scripting Scenarios Guide

The document provides a series of ServiceNow scripting scenarios designed to enhance alert management and event processing. It outlines specific scenarios, solution steps, and common struggles developers may face while implementing these solutions, including setting alert priorities, enriching events with CI information, and automating incident creation. Each scenario includes example code to demonstrate the implementation of the solutions discussed.

Uploaded by

chittynarowdy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views35 pages

ServiceNow Scripting Scenarios Guide

The document provides a series of ServiceNow scripting scenarios designed to enhance alert management and event processing. It outlines specific scenarios, solution steps, and common struggles developers may face while implementing these solutions, including setting alert priorities, enriching events with CI information, and automating incident creation. Each scenario includes example code to demonstrate the implementation of the solutions discussed.

Uploaded by

chittynarowdy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Be Interview-Ready:

Real ServiceNow
Scripting Scenarios
That Separate
Developers from

Experts!

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


1. Automatically Set Alert Priority Based on
Severity and CI Criticality

Scenario: Dynamically assign a priority (1-5) to an alert


when it is created or updated, based on its severity and
the criticality of the associated Configuration Item (CI).
Solution Steps:
• Use a Business Rule on the em_alert table with
the After condition.
• Query the CMDB to get the [Link] of the
alert's CI.
• Use a conditional logic (if/else or switch) to
map [Link] and [Link] to a
final [Link].
• Update the priority field in the Business Rule.

Logic/Code:
(function executeRule(current, previous) {
var ciGr = new GlideRecord('cmdb_ci');
if ([Link](current.configuration_item)) {
var ciCriticality = [Link]('criticality');
// e.g., 'critical', 'high', 'medium'
var alertSeverity = [Link]('severity');
// e.g., 1, 2, 3, 4, 5

// Example Logic: Priority 1 for Critical CI +


Severity 1 or 2.
if (ciCriticality == 'critical' && (alertSeverity
== 1 || alertSeverity == 2)) {
[Link] = 1;

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


} else if (alertSeverity == 1) {
[Link] = 2;
} else {
[Link] = 3; // default for others
}
[Link](); // Must update since it's an
'After' rule
}
})(current, previous);

Common Struggles:
• Forgetting to call [Link]() in
an After Business Rule.
• Not handling cases where the CI might not be found
([Link]() returns false).
• Creating overly complex or unmaintainable mapping
logic.

2. Enrich an Incoming Event with CI


Information

Scenario: When a new event is created, automatically


enrich it by looking up the CI based on a source
identifier (like an IP address or hostname) from the
event payload.
Solution Steps:
• Use a Business Rule on the em_event table with
the Before condition.
• Parse the source or other identifier field from the

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


incoming event.
• Query the cmdb_ci table to find a matching CI (e.g.,
by ip_address or name).
• If a match is found, set the configuration_item field of
the event.

Logic/Code:

(function executeRule(current, previous) {


var eventSource = [Link]; // e.g.,
"[Link]"
var ciGr = new GlideRecord('cmdb_ci');
[Link]('ip_address', eventSource);
[Link]();
if ([Link]()) {
current.configuration_item = ciGr.sys_id;
}
// If no match, the field remains empty
})(current, previous);

Common Struggles:
• Using a Before rule vs. an After rule (Before is more
efficient as it avoids a double update).
• Not considering multiple possible matches in the
CMDB.
• Relying on a single identifier; real-world Scenarios
may need fallback logic (e.g., try IP, then try hostname).

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


3. Suppress Alerts During a Maintenance
Window

Scenario: Prevent alerts from being generated if the


associated CI is in an active maintenance window.
Solution Steps:
• Use a Business Rule on the em_event table with
the Before condition.
• After binding the event to a CI, check if that CI has an
active maintenance schedule.
• Query the cmdb_ci and related maintenance tables
(conceptual).
• If an active maintenance window is found, set a flag or
clear the severity to prevent alert creation.

Logic/Code:

(function executeRule(current, previous) {


var ciId = current.configuration_item;
if (!ciId) return;

// Assuming a relationship from CI to Maintenance


Schedule
var maintGr = new GlideRecord('maintenance_table');
// e.g., 'cmdb_ci_maintenance'
[Link]('ci', ciId);
[Link]('start_date', '<=', new
GlideDateTime());
[Link]('end_date', '>=', new
GlideDateTime());

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


[Link]();
[Link]();

if ([Link]()) {
// Suppress the event by setting a state or low
severity
[Link] = 0; // Or a custom 'suppressed'
state
[Link]('Event suppressed for CI: ' + ciId + '
due to maintenance.');
}
})(current, previous);

Common Struggles:
• Incorrectly querying date ranges for active
maintenance.
• Not understanding the specific table relationships in
their instance.
• Performance issues from complex CMDB/maintenance
queries on every event.

Book a One-on-One Call: Facing challenges with ServiceNow


administration, scripting, integrations, or real-world use cases? Book
a one-on-one call for expert guidance on streamlining administration,
mastering scripting, seamless integrations, and solving Scenario-
based challenges. Click here to schedule!

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


4. Create an Incident Automatically from a
High-Priority Alert

Scenario: Automatically generate an Incident record when


an alert with a priority of 1 or 2 is inserted.
Solution Steps:
• Use a Business Rule on the em_alert table with
the After condition.
• Check if [Link] is 1 or 2.
• Use new GlideRecord('incident') to create a new
incident.
• Populate key fields
like short_description, description, configuration_it
em, and assignment_group.
• Insert the new record and optionally link it back to the
alert.

Logic/Code:

(function executeRule(current, previous) {


if ([Link] < 3) {
var inc = new GlideRecord('incident');
[Link]();
inc.short_description = 'High Priority Alert: ' +
current.short_description;
[Link] = [Link];
inc.configuration_item =
current.configuration_item;
inc.assignment_group = 'Your Support Group
SysID'; // Lookup dynamically

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


var incSysId = [Link]();

// Optionally, link the alert to the incident


[Link] = incSysId;
[Link]();
}
})(current, previous);

Common Struggles:
• Forgetting [Link]().
• Not handling the assignment group lookup
dynamically, leading to hardcoded SysIDs.
• Creating an infinite loop if the incident creation itself
triggers events.

5. Correlate Alerts by Source and Message


Pattern

Scenario: Group multiple alerts from the same source


with a similar error message into a single parent alert to
reduce noise.
Solution Steps:
• Use a Scripted Correlation Rule (often implemented in
a Business Rule or a dedicated correlation engine
script).
• Query existing em_alert records for open alerts from
the same source with a similar description.
• Use a GlideRecord query
with addQuery and addCondition using CONTAINS or LIKE.
• If a match is found, update the new alert to be a child

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


of the existing one, or close it as a duplicate.

Logic/Code:

// This could be in a Business Rule on 'em_alert'


'Before'
(function executeRule(current, previous) {
var source = [Link];
var description = [Link];

var existingAlert = new GlideRecord('em_alert');


[Link]('source', source);
[Link]('state', '!=', 'Closed'); //
Check only open alerts
[Link]('description', 'CONTAINS',
[Link](0, 50)); // Simple pattern
match
[Link]();
if ([Link]()) {
// Correlate by making the new alert a duplicate
of the existing one
current.duplicate_of = existingAlert.sys_id;
[Link] = 'Closed'; // Auto-close the
duplicate
[Link]('Alert correlated and closed as duplicate
of ' + [Link]);
}
})(current, previous);

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


Common Struggles:
• Writing inefficient queries that slow down the alert
insertion process.
• Over-correlating and grouping unrelated alerts due to
a poor pattern-matching strategy.
• Not considering the alert state in the query (e.g.,
correlating with already closed alerts).

6. Validate an Event Payload in a REST API


Script

Scenario: Ensure data integrity for events coming in via a


REST API before they are processed.
Solution Steps:
• Create a Scripted REST API (Scriptable Resource).
• In the post or put method, validate the request body.
• Check for mandatory fields
(e.g., source, severity, message).
• Validate data types and value ranges
(e.g., severity must be between 1-5).

Logic/Code:

(function process(request, response) {


var requestBody = [Link];
var data = {};
try {
data = [Link]([Link]);

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


} catch (e) {
[Link](400);
[Link]({ error: 'Invalid JSON payload'
});
return;
}

// Validate mandatory fields


if (![Link] || ![Link] || ![Link])
{
[Link](400);
[Link]({ error: 'Missing required
fields: source, severity, or message' });
return;
}
if (isNaN([Link]) || [Link] < 1 ||
[Link] > 5) {
[Link](400);
[Link]({ error: 'Severity must be an
integer between 1 and 5' });
return;
}

// If validation passes, create the event


var eventGr = new GlideRecord('em_event');
[Link]();
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
var eventSysId = [Link]();

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


[Link](201);
[Link]({ message: 'Event created
successfully', sys_id: eventSysId });
})(request, response);

Common Struggles:
• Forgetting proper error handling and try/catch blocks.
• Not setting the correct HTTP status codes (e.g., 400 for
bad request, 201 for created).
• Failing to parse the JSON request body correctly.

7. Dynamically Populate an Alert Assignment


Group

Scenario: Automatically assign an alert to a specific group


based on the affected CI's support group.
Solution Steps:
• Use a Business Rule on the em_alert table,
either Before or After.
• Get the CI's sys_id from the alert.
• Query the cmdb_ci record and get
the support_group field.
• Set the alert's assignment_group field to that value.

Logic/Code:

(function executeRule(current, previous) {


var ciSysId = current.configuration_item;

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


if (ciSysId) {
var ciGr = new GlideRecord('cmdb_ci');
if ([Link](ciSysId)) {
var supportGroup = ciGr.support_group; //
Field holding the group SysID
if (supportGroup) {
current.assignment_group = supportGroup;
}
}
}
})(current, previous);

Common Struggles:
• Assuming the CI will always have a support group
without a null check.
• Confusion between Before (direct field set)
and After (requires [Link]()) rules for this
task.
• Not having a fallback group if the CI's support group is
empty.

8. Create a Custom Event Management Utility

Scenario: Build a reusable function to calculate and


update the health score of a Business Service based on
its active alerts.
Solution Steps:
• Create a Script Include with a meaningful name
(e.g., BusinessServiceHealthUtils).

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


• Define a function (e.g., updateHealthScore) that takes a
Business Service sys_id as a parameter.
• Query all active alerts linked to that service via its CIs.
• Apply logic to calculate a health score (e.g., 100 -
(number_of_critical_alerts * 10)).
• Update the business_service record with the new
score.

Logic/Code:

var BusinessServiceHealthUtils = [Link]();


[Link] = {
initialize: function() {},
updateHealthScore: function(serviceSysId) {
var alertGr = new GlideAggregate('em_alert');

[Link]('configuration_item.business_servic
e', serviceSysId);
[Link]('state', 'IN',
'New,Acknowledged');
[Link]('COUNT');
[Link]('severity');
[Link]();

var penalty = 0;
while ([Link]()) {
var count = [Link]('COUNT');
var severity = [Link]('severity');
// Higher severity alerts incur a larger
penalty

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


if (severity == 1) penalty += (count * 20);
// Critical
if (severity == 2) penalty += (count * 10);
// Major
}
var healthScore = [Link](0, 100 - penalty); //
Ensure score doesn't go below 0

var serviceGr = new


GlideRecord('business_service');
if ([Link](serviceSysId)) {
serviceGr.health_score = healthScore;
[Link]();
[Link]('Updated health score for ' +
[Link]() + ' to ' + healthScore);
}
},
type: 'BusinessServiceHealthUtils'
};

Common Struggles:
• Incorrectly using GlideAggregate for counting records.
• Writing inefficient queries that perform poorly on
large data sets.
• Not understanding the relationship path from Alert ->
CI -> Business Service.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


9. Implement a UI Policy for Alert Triage

Scenario: On the Alert form, make the "Resolution Notes"


field mandatory only when the state is changed to
"Resolved".
Solution Steps:
• Create a UI Policy on the em_alert table.
• Set the condition: State - changes to - Resolved.
• In the Actions, set the "Resolution Notes" field
to Mandatory = true.
• Add a reverse condition for when state
changes from Resolved to set it back to false.

Logic/Code:
(UI Policies are configurable, but script can be added)

// In the "Script" action of the UI Policy, you can add


additional logic if needed.
g_form.setMandatory('resolution_notes', true);
// Reverse UI Policy would set it to false.

Common Struggles:
• Forgetting to create the reverse UI Policy, leaving the
field mandatory incorrectly.
• Confusing UI Policies with Client Scripts (UI Policies
are server-side and run on form load/refresh).
• Not testing the behavior when the state is
changed from Resolved.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


10. Log All Alert State Changes for Auditing

Scenario: Track every time an alert's state is modified,


recording who changed it and when.
Solution Steps:
• Use a Business Rule on the em_alert table with
the After condition and isNew() method to skip inserts.
• Compare [Link] with [Link].
• If they are different, create a new record in a custom
audit table or add to the alert's journal fields.

Logic/Code:

(function executeRule(current, previous) {


if (![Link]() && [Link] !=
[Link]) {
var auditGr = new GlideRecord('sys_audit'); // Or
a custom table
// ... populate audit record with old value, new
value, user, timestamp, etc.
[Link]('Alert ' + [Link] + ' state
changed from ' + [Link] + ' to ' +
[Link] + ' by ' + [Link]().getName());
}
})(current, previous);

Common Struggles:
• Using Before Business Rule where previous object is
not available.
• Not using ![Link]() to avoid logging
the initial insert.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


• Performance impact of creating an audit entry for
every update, not just state changes.

11. Synchronize Alert Closure with Related


Incident

Scenario: When an Incident linked to an Alert is closed,


automatically close the Alert as well.
Solution Steps:
• Use a Business Rule on the incident table with
the After condition.
• Check if the incident's state has changed to a closed
state (e.g., 6 or 7).
• Query the em_alert table for alerts
where incident field matches the current incident.
• Update the state of all found alerts to "Closed".
Logic/Code:

(function executeRule(current, previous) {


// Check if incident was just closed
if ([Link] != [Link] && ([Link]
== 6 || [Link] == 7)) {
var alertGr = new GlideRecord('em_alert');
[Link]('incident', current.sys_id);
[Link]();
while ([Link]()) {
[Link] = 'Closed';
[Link]();

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


}
}
})(current, previous);

Common Struggles:
• Incorrectly identifying the numeric state values for a
closed incident.
• Creating a circular reference if alert closure also tries
to update the incident.
• Not considering that multiple alerts could be linked to
a single incident.

12. Batch-Clear Old, Closed Alerts

Scenario: Create a scheduled job to automatically delete


alerts that have been in a "Closed" state for more than
90 days.
Solution Steps:
• Create a Scheduled Script Execution.
• Use GlideRecord to query em_alert where state is
'Closed' and sys_updated_on is older than 90 days.
• Use deleteMultiple() to remove the records in
batches for performance.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


Logic/Code:

var clearDate = new GlideDateTime();


[Link](-90);
var alertGr = new GlideRecord('em_alert');
[Link]('state', 'Closed');
[Link]('sys_updated_on', '<=', clearDate);
[Link](); // More efficient than deleting
in a loop
[Link]('Scheduled job executed: Old closed alerts
cleared.');

Common Struggles:
• Using a while loop with [Link]() and [Link](),
which is less efficient than deleteMultiple().
• Accidentally using sys_created_on instead
of sys_updated_on to determine staleness.
• Not considering corporate data retention policies
before implementing such a script.

Book a One-on-One Call: Facing challenges with ServiceNow


administration, scripting, integrations, or real-world use cases?
Book a one-on-one call for expert guidance on streamlining
administration, mastering scripting, seamless integrations, and
solving Scenario-based challenges. Click here to schedule!

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


13. Generate a Summary Report of Active
Alerts by Business Service

Scenario: Create a background script that runs hourly and


emails a summary of all non-closed alerts, grouped by
Business Service.
Solution Steps:
• Create a Scheduled Script Execution.
• Use GlideRecord and GlideAggregate to query and
count active alerts grouped by business_service.
• Build an HTML or plain text email body with the
results.
• Use [Link] or Email REST API to send the
email.

Logic/Code:

var agg = new GlideAggregate('em_alert');


[Link]('state', 'NOT IN', 'Closed');
[Link]('COUNT');
[Link]('configuration_item.business_service.name');
[Link]();

var emailBody = "<h2>Active Alert Summary</h2><ul>";


while ([Link]()) {
var serviceName =
[Link]('configuration_item.business_service.na
me');
var count = [Link]('COUNT');

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


emailBody += "<li>" + serviceName + ": " + count + "
alert(s)</li>";
}
emailBody += "</ul>";

// Send email (conceptual - requires proper email


configuration)
[Link]('[Link]', current, emailBody,
'admin@[Link]');

Common Struggles:
• Complex GlideAggregate queries across reference
fields.
• Building the HTML email content correctly.
• Configuring the outbound email action properly.

14. Validate a Custom Event Rule


Configuration

Scenario: Prevent users from saving an Event Rule with


an empty condition field.
Solution Steps:
• Use an onSubmit Client Script on the Event Rule form
(table sysevent_register or similar).
• Check if the condition field is empty.
• Use g_form.showFieldMsg() to display an error
and return false to prevent submission.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


Logic/Code:

function onSubmit() {
var condition = g_form.getValue('condition_field');
// Get the condition field value
if (!condition || [Link]() == '') {
g_form.showErrorBox('condition_field', 'Condition
cannot be empty.');
return false; // Prevent save
}
return true; // Allow save
}

Common Struggles:
• Using the wrong Client Script type (onSubmit is needed
to block form submission).
• Not getting the correct HTML field name
for g_form.getValue().
• Forgetting to return false to cancel the save
operation.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


15. Automatically Acknowledge Alerts from
Specific Sources

Scenario: Immediately acknowledge any new alert that


comes from a "monitoring-tool-2" source.
Solution Steps:
• Use a Business Rule on the em_alert table with
the After condition.
• Check if [Link] contains "monitoring-tool-2".
• If true, set the alert's state to "Acknowledged".

Logic/Code:

(function executeRule(current, previous) {


if ([Link]('monitoring-tool-2') != -
1) {
[Link] = 'Acknowledged';
[Link]();
}
})(current, previous);

Common Struggles:
• Using a Before rule for this is simpler and more
efficient, as it avoids the update() call.
• Over-acknowledging alerts due to a poorly defined
source string.
• Not considering if this auto-acknowledgment should
also trigger notifications.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


16. Populate a Alert's Short Description from
Event Payload

Scenario: For events coming via a web service,


the short_description is not mapped. Create it by
combining the source and the first 100 characters of the
message.
Solution Steps:
• Use a Business Rule on the em_event or em_alert table
with the Before condition.
• Concatenate the source and description fields.
• Use substring to limit the length and set
the short_description field.

Logic/Code:
(function executeRule(current, previous) {
var source = [Link] || 'Unknown';
var desc = [Link] || '';
var shortDesc = source + ': ' + desc;
if ([Link] > 100) {
shortDesc = [Link](0, 99) + '...';
}
current.short_description = shortDesc;
})(current, previous);

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


Common Struggles:
• Not handling null values for source or description.
• Creating a short description that is too long for the
field.
• Doing this in the wrong table (em_event vs. em_alert).

17. Escalate an Alert if Not Acknowledged in


15 Minutes

Scenario: Change an alert's priority to a higher level if it


remains in "New" state for more than 15 minutes.
Solution Steps:
• Use a Scheduled Job that runs every 5 minutes.
• Query for alerts where state is 'New'
and sys_created_on is older than 15 minutes.
• Update the priority field for these alerts.

Logic/Code:

var timeThreshold = new GlideDateTime();


[Link](-15);
var alertGr = new GlideRecord('em_alert');
[Link]('state', 'New');
[Link]('sys_created_on', '<=', timeThreshold);
[Link]();
while ([Link]()) {

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


[Link] = [Link] - 1; // Increase
priority (if 1 is highest)
[Link]();
}

Common Struggles:
• Incorrect date/time arithmetic with GlideDateTime.
• Performance issues if the query returns a very large
number of alerts.
• Not considering that the alert might have been
acknowledged just before the job ran.

18. Create a Diagnostic Script for Event Rule


Testing

Scenario: Build a Fix Script or Background Script that can


simulate an event and run it through the Event
Management pipeline for debugging.
Solution Steps:
• Create a Fix Script (for admin use).
• Manually create an em_event record with test data.
• Use EventQueue or EventManagementUtil to process the
event (if available) or simply insert it.
• Log the resulting alert (if any) for inspection.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


Logic/Code:

// This is a diagnostic script, typically run in a Fix


Script background
var eventGr = new GlideRecord('em_event');
[Link]();
[Link] = 'Test Script';
[Link] = 2;
[Link] = 'Test CI';
[Link] = 'This is a test event generated by
a diagnostic script.';
[Link] = 'Test Node';
var eventSysId = [Link]();

[Link]('Test Event created: ' + eventSysId);


// The event will be processed by the standard EM
pipeline, potentially creating an alert.

Common Struggles:
• Not having the necessary fields populated for the
event to be processed correctly.
• Not knowing the correct way to programmatically
trigger event processing.
• Forgetting to clean up test events/alerts after
debugging.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


19. Update a CI's Operational Status Based on
Active Alerts

Scenario: Set a CI's operational state (e.g., "Operational",


"Degraded", "Down") based on the highest severity of its
active alerts.
Solution Steps:
• Create a Business Rule on the em_alert table that
runs After insert, update, or delete.
• Get the alert's CI.
• Query all active alerts for that CI to find the highest
severity.
• Map the highest severity to an operational state and
update the CI.

Logic/Code:

(function executeRule(current, previous) {


var ciSysId = current.configuration_item;
if (!ciSysId) return;

var alertGr = new GlideRecord('em_alert');


[Link]('configuration_item', ciSysId);
[Link]('state', 'NOT IN',
'Closed,Resolved');
[Link]('severity', '!=', '0'); // Ignore
info alerts

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


[Link]('severity'); // Get the highest
severity first
[Link](1);
[Link]();

var newState = 'Operational'; // Default


if ([Link]()) {
var maxSev = [Link];
if (maxSev == 1) newState = 'Down';
else if (maxSev == 2) newState = 'Degraded';
}

var ciGr = new GlideRecord('cmdb_ci');


if ([Link](ciSysId)) {
ciGr.operational_status = newState;
[Link]();
}
})(current, previous);

Common Struggles:
• Writing an inefficient query inside a Business Rule that
fires on every alert change.
• Not handling the case where the last alert for a CI is
closed, requiring the status to revert to "Operational".
• Updating the CI on every alert change, even when the
operational state hasn't actually changed.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


📃📄 ADDITONAL
RESOURCES 📃📄
SEASON 1:
SCRIPTING SERIES
Part_1: [Link]
Part_2: [Link]
Part_3: [Link]
Part_4: [Link]
Part_5: [Link]
Part_6: [Link]
Part_7: [Link]
Part_8: [Link]
Part_9: [Link]
Part_10: [Link]
Part_11: [Link]
Part_12: [Link]
Part_13: [Link]
Part_14: [Link]
Part_15: [Link]
Part_16: [Link]
Part_17: [Link]
Part_18: [Link]
Part_19: [Link]
Part_20: [Link]

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


SEASON 2:
SCRIPTING SERIES
Part_1: [Link]
Part_2: [Link]
Part_3: [Link]
Part_4: [Link]
Part_5: [Link]
Part_6: [Link]
Part_7: [Link]
Part_8: [Link]
Part_9: [Link]
Part_10: [Link]
Part_11: [Link]
Part_12: [Link]
Part_13: [Link]
𝗣𝗮𝗿𝘁_𝟭4: [Link]
Part_15: [Link]
Part_16: [Link]
Part_17: [Link]
Part_18: [Link]
Part_19: [Link]
Part_20: [Link]

Book a One-on-One Call: Facing challenges with ServiceNow


administration, scripting, integrations, or real-world use
cases? Book a one-on-one call for expert guidance on
streamlining administration, mastering scripting, seamless
integrations, and solving Scenario-based challenges. Click
here to schedule!

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


SEASON 3:
SCRIPTING SERIES
Part_1 : [Link]
Part_2 : [Link]
Part_3 : [Link]
Part_4 : [Link]
Part_5 : [Link]
Part_6 : [Link]

Integration
Series
SOAP GUIDE : [Link]
Integration eBook : [Link]

Need Help? Join Our WhatsApp Community — Struggling with


ServiceNow administration, scripting, integrations, or real-world use
cases? Don’t worry! Get real-time support, tips, and advice from
experts and peers on the same journey. You’re not alone—we’re here
to help you succeed.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


1.

©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]


©️HackNow Call/WhatsApp: +91 8984988593 Visit Us: [Link]

You might also like