Background Scripts

Badal Khojare
Mega Sage
Mega Sage

Background Scripts are Server side scripts that can be immediately run on ServiceNow instance and can be very helpful if you want to try scripts out or fix minor issues on records.

 

To write a Background Script Go to Application Navigator > Scripts - Background. A window will be opened to write your script into.

BadalKhojare_0-1674963688801.png

 

 

 

There are a few options/checkboxes at the bottom of the window that function pretty much as their name would suggest :

BadalKhojare_1-1674963758513.png

 

 

  • Run script: This a button that Runs the script in the Run script window on the server side.

 

  • in scope: This is a drop down that allows you to run the script in different scope outside of global if required.

 

  • Record for rollback?: This checkbox if checked allows you to rollback the results of executed script. This is checked by default. This can be done from Rollback and Recovery > Script Execution History. Then Script Execution History is available for 7 days.

                          BadalKhojare_2-1674965696099.png

  

 

 

  • Execute in sandbox: This is a checkbox that allows script to run with sandbox like restrictions. If checked, data       cannot be inserted, updated or deleted.

 

  • Execute as scriplet? : This is a checkbox which if selected allows the script to execute as a scriplet which means it will have access to the global scope and any server side functionality or objects. If the checkbox is not selected the script will be executed in global scope  but will not have access to  any server side functionality or objects.

 

  • Cancel after 4 hours: This is a checkbox which cancels the script execution if it continues running after 4 hours. This checkbox is checked by default. 

BadalKhojare_3-1674970038905.png

If you cannot see the background script option, it means you would need additional privileges to access background scripts. In this case you would need 'security_admin' role. This is managed via a system property that allows only users with elevated privileges to access background scripts.

 

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023
2 REPLIES 2

Rajat_Choudhary
Tera Expert

Hello @Badal Khojare ,

 

You explained the Background script very nicely.

One suggestion.

You can create this as an article.

 

 

Hope this answers will be helpful.
Please mark the answer as helpful and correct.

Best Regards,
Rajat Choudhary

Hi Rajat,

Thankyou. Yes, I was looking to create it as an article and thought I had created it as an article, but I did not 🙂 I will check back again and post it as an article. 

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023