Learning Javascript for ServiceNow

LachieS
Tera Contributor

Hello Everyone,

 

I am new to ServiceNow and have a background in software engineering. When I first learned to code in Java, there were plenty of online resources to help me grasp the fundamentals and practice in sandbox environments.

Now that I'm transitioning my skills from an OOP language to Javascript, I'm feeling a bit overwhelmed by the differences and don't know what specifics I should be learning to progress as a ServiceNow developer. 

 

Does anyone know of good resources with content tailored to real ServiceNow scenarios, that aren't necessarily the foundations of programming? 

Thanks!

 

8 REPLIES 8

Anand Kumar P
Giga Patron

Hi @LachieS ,

Learn JavaScript methods and then go to ServiceNow APIS client side and server side
JavaScript methods: 
https://www.servicenow.com/community/developer-advocate-blog/learn-more-javascript-on-the-servicenow...
https://www.servicenow.com/community/in-other-news/javascript-learning-path-from-zero-to-hero/ba-p/2...

Statements And Syntax in JavaScript

Components of JavaScript statements

Variables

Types of Variables in JavaScript

Operators in JavaScript

Data Types in JavaScript

Strings

Datatype Conversions

Conditions

Type of conditions

Loops

Functions

Arrays

Strings

Objects

JSON

 

 

ServiceNow API's : 

Key components include:

Client side: 
https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/client/

Server Side: https://developer.servicenow.com/dev.do#!/learn/courses/xanadu/app_store_learnv2_scripting_xanadu_sc...
https://www.servicenowelite.com/blog/2014/2/19/client-vs-server

Client Script: Custom JavaScript that runs on the client side to apply logic based on user actions or form events.

UI Policies: Rules that dynamically change form information and behavior without writing a script.

UI Scripts: Reusable JavaScript code that can be included in pages and forms across the ServiceNow platform.

 

Server-side scripting in ServiceNow occurs when a user action leads to a request sent to the server, such as updating, inserting, or deleting records. Scripts running on the server can modify ServiceNow's functionality or appearance, enforce business logic, or handle record operations. Server-side scripting is powered by Glide APIs, offering a suite of classes and methods for executing tasks on the server.

 


Client Side APIs:

1. Glide Form (g_form): Used for manipulating and managing the form interface. It can get or set field values, add error messages, or change field properties.
 Ex: `g_form.setValue('short_description', 'Issue with login');`

2. Glide User: Allows access to information about the current user from the client side, such as user ID or display name.
Ex: `var userName = g_user.displayName;`

3. Glide Ajax: Enables the execution of server-side code from the client side asynchronously. It's used to retrieve data without reloading the page.
Ex:  var ga = new GlideAjax('HelloWorld');
  ga.addParam('sysparm_name', 'helloWorld');
  ga.getXML(doSomethingWithResponse);

4. Glide Dialog Window: Provides a way to create and control dialog windows. It's useful for displaying forms or information without navigating away from the current page.
Ex: `var dialog = new GlideDialogWindow('dialog_id'); dialog.render();`

5. Glide List: Allows manipulation and interaction with list fields on a form, including adding or removing items.
 Ex: `g_form.addOption('watch_list', 'sys_id', 'name');`

6. Glide List Menu: Used to interact with and customize the context menus in list views.
Ex: Adding custom menu items to a list's context menu.

Server Side APIs:

1. Glide Record: Enables database operations such as creating, reading, updating, and deleting records.
Ex: var gr = new GlideRecord('incident');
  gr.get('sys_id', 'someSysId');
  
2. Glide System: Offers methods for logging, querying system information, and other utility functions.
Ex: `gs.info('This is an info message');`

3. Glide Date: Provides methods for working with dates on the server side, excluding time.
Ex: var gd = new GlideDate();
  gd.setValue('2023-01-01');
  
4. Glide Date Time: Allows for manipulation of date and time, including calculations and formatting.
Ex: var gdt = new GlideDateTime();
  gdt.addDaysLocalTime(5);
  
5. Glide Aggregate: Used for aggregate queries, such as COUNT, SUM, AVG, MIN, and MAX on records.
Ex: var agg = new GlideAggregate('incident');
  agg.addAggregate('COUNT');
  agg.query();
 
6. Glide Element: This represents a field on a GlideRecord and allows for field-specific operations like changing the value or retrieving the display value.
Ex: `var incidentState = current.state.getDisplayValue();`

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand



PrashantLearnIT
Giga Sage

Hi @LachieS 

 

You can refer to this one - https://www.servicenow.com/community/in-other-news/javascript-learning-path-from-zero-to-hero/ba-p/2...

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

B_Engelstock
Tera Expert

I found this online training usefull:

https://www.udemy.com/course/servicenow-201-development/

 

Ravi Chandra_K
Kilo Patron
Kilo Patron

This helped me a lot when I was learning JS on Now platform!

Chuck walks you through simple concepts to ServiceNow APIs till the end of this playlist. On continuation to that, Earl also added Learn more JS videos to this playlist.

https://youtube.com/playlist?list=PL3rNcyAiDYK2_87aRvXEmAyD8M9DARVGK&si=bIv9aTkYjc089ZKh