While powerful, Background Scripts can be dangerous. If you aren’t careful, you can delete all kinds of important or system-critical records. Even more likely, a poorly written script might run indefinitely, causing system performance issues.
- As an admin, use the lock icon to elevate your privileges to “security_admin”.
- Look in the left-hand navigation for “ -> Background Scripts”, and click away.
- Once you input your script, you’ll click “Run”. The system will run your script, and you’ll see output as pictured below.
- One excellent tip, is that you can use “gs.print()”, to output things from your background script, without having them be entered into the system log – that’s what I’ve done in the image above.
It is possible to permanently store scripts on the Background Scripts page for use later. In order to do so, you’ll have to write your script in an outside editor, and upload it. These aren’t captured in update sets, so treat them like data.
- Write your script and save it with a “.js” file extension – be sure to test it first to make sure it runs as you would expect!
- In the left hand menu, look for “Upload File”.
- Navigate to Background Scripts (remember to elevate to security admin if need be).
- By clicking on the blue link of your script, it will be run instantly, showing your output like normal.
- If you ever need to delete one of these scripts, visit the table “v_customer_uploads”, and delete the corresponding record there.
Have any comments or creative uses for background scripts? Share them in the comments! I’m always looking for new ideas.