Skip to content

Commit 59f94c1

Browse files
authored
Create README.md
1 parent d409d6e commit 59f94c1

File tree

1 file changed

+27
-0
lines changed
  • Server-Side Components/Script Includes/NonProdLogUtils

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
To create a logging utility in a ServiceNow Script Include that only logs in non-production environments, you can follow these steps:
2+
3+
4+
Create a new Script Include.
5+
Define a utility class with a logging function.
6+
Inside the function, get the instance name and use conditional logic to check if it matches the production instance name.
7+
If the instance is non-production, execute the logging command.
8+
Call this utility from other server-side scripts.
9+
10+
11+
This method centralizes your logging logic, making it easy to manage.
12+
Step 1: Create the Script Include
13+
In the main navigation, type Script Includes and select it under System Definition.
14+
Click New to create a new record.
15+
Fill out the form with the following details:
16+
Name: LoggingUtils
17+
Accessible from: All application scopes (This allows you to call the function from anywhere).
18+
Client callable: Unchecked (This is a server-side utility).
19+
20+
21+
22+
23+
// Instantiate the Script Include
24+
var logUtil = new LoggingUtils();
25+
26+
// Use the log() function to log a message
27+
logUtil.log('Hackertoberfest', 'info');

0 commit comments

Comments
 (0)