Working with background scripts
A background script is a place where you can test your server-side scripts, which is same as free text box. To access the background script, you should have a security_admin
role with elevated privileges.
Getting ready
To step through this recipe, you should have an active Service-Now instance, valid credentials, and a security admin role.
How to do it...
- Open any standard web browser and type the instance address.
- On the left-hand side, type
background
in the search box and Service-Now will search the module for you. - Click on the
Scripts
-
Background
module underSystem Definition
application, as shown here:
![](https://static.packt-cdn.com/products/9781788628730/graphics/74d5eb66-0b5f-497b-9687-0b8fb7fb28aa.png)
Background script module
- Now you will be able to see the following screen, where you can place your code and click on the
Run
script
button:
![](https://static.packt-cdn.com/products/9781788628730/graphics/e6fd529f-b0d5-4895-a6b6-3a4d460838f4.png)
Run script
- Service-Now has an inbuilt
gs.print()
function, which is used to view the output of the script and it also write an entry in a log file, but thegs.log ()
functions in write an entry in the system log and log file...