ServiceNow CLI - an interesting feature to play with SN using REST API calls
The ServiceNow CLI is a command-line interface that lets us to perform instance operations from our local system. We can extend the CLI to include new commands that meet the application's needs.
Benefits
The ServiceNow CLI lets us to:
- Perform basic CRUD operations on records in SN instance.
- Develop custom components and deploy them to SN instance to personalize a UI.
- Create custom commands that enable to manage custom applications from the command line.
- Use the ServiceNow CLI in scripts to simplify setup tasks and operational activities.
Architecture
Commands are stored in a table on the instance where we are connected to. When the ServiceNow CLI connects to the instance, it receives all the available commands supported by that instance. Commands map to a REST endpoint that executes asynchronously.
Activating ServiceNow CLI in Windows machine:
Here are the steps I followed to run this functionality successfully from my personal laptop using my PDI
- Download the CLI client from SN store and here is the link: https://store.servicenow.com/sn_appstore_store.do#!/store/application/9085854adbb52810122156a8dc961910/1.1.0?referer=%2Fstore%2Fsearch%3Flistingtype%3Dallintegrations%25253Bancillary_app%25253Bcertified_apps%25253Bcontent%25253Bindustry_solution%25253Boem%25253Butility%25253Btemplate%26q%3DCLI&sl=sh
- Make sure to have the CLI Metadata plugin installed in the SN instance.
- Make sure to have the SNC Client path should be set in the PATH variable (Environment) [Eg:C:\Users\urspv\.snc]
SN CLI Path and profile config setup:
This is the path where we have all the necessary files are useful to run this CLI functionality
This is the command to run after CLI installation done from the store. With this we are creating config.json file and /default folder where we have the commands.json file mentioned below
Sample commands from command line using "snc record" command:
- This is for list of all incidents from SN PDI instance after successful REST API call done using the below command
- This is to create a new incident in SN instance using REST service call on table API
- End result after adding a new record from the command line
References:
1) www.Google.com
2) https://docs.servicenow.com/
3) https://developer.servicenow.com/
4) https://store.servicenow.com/sn_appstore_store.do#!/store/home
5) https://github.com/ServiceNow/servicenow-cli







