Table of contents
Introduction
Imagine combining the best of both worlds: the sleek, versatile coding power of Visual Studio Code (VS Code) and the functionality-packed SN Utils extension for ServiceNow. Sounds like a developer’s dream, right? Well, buckle up because we’re about to make that dream a reality! With just a few clicks, you’ll be able to write and edit your ServiceNow scripts in the VS Code environment you love, while SN Utils quietly handles syncing everything back to ServiceNow. No more endless clicking through menus or waiting for the platform’s script editor to catch up with you. In this blog, we’ll show you how to marry these two tech tools so seamlessly that your code will practically write itself (well, almost). Let’s dive into this code magic and have some fun while we’re at it!
Prerequisites
1) Download and add SN Utils Extensions On Your Browser
2) Download and install VS Code On Your Device.
3) Once VS Code is installed, open the extensions tab i.e. the 5th tab on the left. (Marked in Red in the image below)
4) Search for sn-scriptsync extension and install it.
Once the setup’s done, you’re all set to learn how VS Code and SN Utils sync your code with ServiceNow like clockwork!
The Fun Begins
1) Navigate to VS Code and Select Any Folder, where you want your code to reside.
Once the folder is opened, the name of the folder will be displayed on the left side
2) On the right side of the below, you will see an option to start sn-scriptsync. Click on that to start the synchronization process.
3) Hop into your ServiceNow instance and open any script—whether it's a Business Rule, Client Script, Script Include, or even a Widget (if you're feeling fancy). For this blog, though, we’ll be focusing on Script Include, so let’s crack that one open and see what’s under the hood!
4) Find the script section and click on the icon present with the Script text.(Refer to the image below)
5) You can see that the script include is now open in VSCode,
6) You write and save code from VS Code now and it will reflect directly on the ServiceNow instance.
And there you have it. Now, you don’t have to wait for the proper formatting to kick in in ServiceNow as it can be easily done from VSCode.
Ending Note
Congrats! You've jumped through the setup hoops and tamed the beasts that are VS Code and SN Utils, and now you're ready to unleash your coding magic. With your trusty tools, you're all set to dive into development like a coding superhero—cape optional, but highly encouraged. Let the code flow and may the bugs be ever in your favor!