ServiceNow Sync 2021
Allows you to save and edit ServiceNow records from Visual Studio Code.
-- Based on a fork from ServiceNow Sync extension built by anerrantprogrammer --
Installation
Install from marketplace
Install extension from the Visual Studio Marketplace.
Build and install locally
Clone the repository locally, and package it in a .vsix file so that it can be installed into VS Code.
To do so, from the cloned repository folder, run:
vsce package
This will create a servicenow-sync-2021-0.3.0.vsix
file which you can then share, or install using the following command line:
code --install-extension servicenow-sync-2021-0.3.0.vsix
Note that the original 'ServiceNow Sync' extension should either be disabled or uninstalled when using this 2021 version.
Usage
Setting up the extension
ServiceNow Sync depends on the root workspace folder, base settings will be stored in this folder. It is recommended that you create a working folder per each instance you wish to sync with.
Connecting to a ServiceNow instance
- From a working folder, open the Command Palette (Ctrl+Shift+P).
- Select 'SN Sync: Connect To ServiceNow'.
- Enter the full instance URL (example
https://myinstance.service-now.com/
).
- Enter the username.
- Enter the password.
A service-now.json
file will be created in the root workspace folder.
Setting up a ServiceNow table for synchronization
- From the working folder which is set up with a ServiceNow instance, open the Command Palette (Ctrl+Shift+P).
- Select 'SN Sync: Sync Table'.
- Select the table from the Quick Pick List.
A folder will be created in the root workspace folder and will contain a service-now.json
file. You may override the default settings by changing this file directly.
files
is a list of synchronized files, you may remove or change entries in this list as long as the given name matches the file name and the sys id matches the id of the record within ServiceNow.
extension
is the file extension to be used when creating files.
table
is the table to synchronize the folder with.
display
is the display field (usually name).
field
is the body field to synchronize the file with.
Some tables - like sys_ui_page
synchronize to multiple fields and these tables will be created with two or more sub-folders, each with their own individual settings.
To sync with a custom table, select 'Custom Table' in the Quick Pick List and follow the prompts to sync the table.
File management
Pulling a file from ServiceNow
- Right click on a synchronized folder from the Explorer view.
- Select 'SN Sync: Sync Record'.
- A list of all records in the table will pop up, select the record by the name (or sys id).
If the file does not exist, it will be created in the folder and the entry added to the files
list in the service-now.json
file.
Pulling multiple files from ServiceNow
- Right click on a synchronized folder from the Explorer view.
- Select 'SN Sync: Sync Multiple Records'.
- Enter an encoded query (example
sys_active=true
).
- If matching records are found the system will confirm you wish to create or overwrite the files locally.
- Select 'Yes' to continue.
All files will be created in the folder and their entries added to the service-now.json
file.
Pushing changes to ServiceNow
- While working in a file that is in a synched folder, save the file as you normally would.
- If the remote file has not changed since the last sync, the remote file will be updated.
- If the remote file has changed you will prompted to overwrite the changes, if you select 'No' the file will be saved locally but not remotely.
Updating local version version of a file
- Right click on a synchronized file and select 'SN Sync: Compare File to Server'
- If the remove file has been updated, you will be prompted to overwrite the local file, if you select 'No', no changes will be made.
Opening a file in the browser
- Right click on a synchronized file and select 'SN Sync: Open Record In Browser'
The ServiceNow record synchronized with the file is opened in your default web browser.
Creating Files in ServiceNow
This feature is not available.
Script execution
Executing File in background script
- While working in a file that is in a synched folder, open the Command Palette (Ctrl+Shift+P).
- Select 'SN Sync: Execute in background script'.
The current file is executed as ServiceNow's background script and results are displayed in the VS Code's 'SN-Sync' Output window.
Setting scope for background script execution
- While working in a file that is in a synched folder, open the Command Palette (Ctrl+Shift+P).
- Select 'SN Sync: Set Scope for background script execution'.
- A list of all available scopes for background script execution will pop up, select the desired scope by its name or sys id.
All subsequent file execution will using 'SN Sync: Execute current file in background script' will be in the selected scope.
Proxy Support
To enable a proxy
- Run the command 'SN Sync: Configure Proxy Settings'
- Set the URL to the base URL of the proxy (http://myproxy)
- Set the Port if there is one
- Set the Username and Password if the Proxy uses Basic Auth
To disable the proxy
- Run the command 'SN Sync: Configure Proxy Settings'
- Set the URL to blank