how many types of client scripts in serviceNow?

NarayanR
Mega Explorer

Hi Family,

 

Can anyone tell me How Many types of client scripts in serviceNow?

 

Many Thanks,

Ram Patil

4 REPLIES 4

Dr Atul - LNG
Tera Patron

Hi @NarayanR 

 

  • Client scripts allow JavaScript to run on the client (web browser) when events occur, such as form load, submission, or field value changes. They are used to configure forms, fields, and values dynamically while the user interacts with the form .
  • Client scripts can make fields hidden or visible, read-only or writable, optional or mandatory based on user role, set field values based on other fields, modify choice lists, and display messages based on field values. However, they are not intended to protect data; use Access Control Lists (ACLs) or data policies for sensitive data protection (Access Control Lists, Data policy) .
  • Types of client scripts include:
    • onLoad(): Runs when the form is rendered, typically for client-side manipulation or setting default values.
    • onSubmit(): Runs when the form is submitted, used for validation and can cancel submission.
    • onChange(): Runs when a field value changes, with parameters for control, oldValue, newValue, isLoading, and isTemplate.
    • onCellEdit(): Runs when a list editor changes a cell value, with parameters for sysIDs, table, oldValues, newValue, and callback .
  • Client scripts are generally supported on forms and search pages, but not on ServiceNow mobile applications. For Service Portal, scripts must have UI Type set to All or Mobile / Service Portal, and only supported client-side APIs can be used .
  • Validation scripts, UI scripts, UI Actions, and UI Policies have specific support and limitations in Service Portal. UI Macros and Formatters are not supported .
  • The client-side Glide API provides classes and methods for scripting, with limitations in Service Portal and Mobile environments. For more details, see Client API reference and Mobile client GlideForm scripting and migration .
  • If you need to restrict field values on lists, use access controls, business rules, data policies, or disable list editing .

Let me know if you need more details about client script APIs, Service Portal support, or access control options.

****************************************************************************************
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************

Ankur Bawiskar
Tera Patron

@NarayanR 

this is an easy question.

Answer to this can be easily found on docs or on google search which would save your time. link here

what's your exact question and confusion?

Screenshot 2026-10-19 131803.png

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

glideFather
Tera Patron

ahoy @NarayanR,

 

you can refer to this resource, it will both explain you the types and differences of client scripts as well as gives you chance to try it yourself in your PDI: Client-side Scripting

 

 

__EDIT__

Be aware that there are client scripts (sys_script_client, for native UI/backend) and catalog client scripts (catalog_script_client, for portals), they can be written similarly but they are stored in different tables:

glideFather_0-1792402347443.png

Navigate to either one:

https://yourDomain.service-now.com/nav_to.do?uri=sys_script_client.do

https://yourDomain.service-now.com/nav_to.do?uri=catalog_script_client.do

 

and check the Type field to see the 4 options:

glideFather_1-1792402519411.png

 


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

Aditya_hublikar
Giga Sage

Hello @NarayanR ,

 

In ServiceNow, there are four main types of Client Scripts that execute JavaScript code within the user's browser .

Aditya_hublikar_0-1792399525998.png

 

You can refer this community thread :

https://www.servicenow.com/community/developer-articles/client-script/ta-p/2827916

 

 

Official documentation :

https://www.servicenow.com/docs/r/api-reference/scripts/client-scripts.html

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya