Skip to content

Instantly share code, notes, and snippets.

@icerge
Last active April 12, 2024 02:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icerge/a7290f902f5c5d8d4baf0bf472613426 to your computer and use it in GitHub Desktop.
Save icerge/a7290f902f5c5d8d4baf0bf472613426 to your computer and use it in GitHub Desktop.
Development and configuration patterns in ServiceNow

Ajax calls from Native forms and Catalog items

Client script + UI Script + Script Include (Ajax) + Script Include (API)

Client script is a calling side. Optionally, it may be wrapped into a UI Script to form re-usable Client side API.

Script Include (Ajax) is an interface for client side interactions it fetches parameters, validate them and call necessary APIs.

Script Include (API) implements server side functionalities that may and most probably will be used by both Client and Server side logic. No Ajax parameters are available in context, they are supplied as method arguments.

Naming convention

Client script must describe the activity it performs.

UI Script forms a library of shared and re-usable functions. The name must point to the domain area it is related (D1imUtils) or functionality it contains (DateTimeUtils).

Script Include (Ajax) must be named according to the user interface it supports e.g. D1imCatalogItemAjax. The name must end with Ajax suffix.

Script include (API) naming principle is similar to UI Script. It is also a library of shared and re-usable functions. Though, the use case of Script includes is much wider. So, there is no exact rule how to name them. Follow code convention guides from you team. Or at least common sense.

Example names

  • Client script: On Group change
  • UI Script: D1imUtils
  • Script include (Ajax): D1imCatalogItemHelperAjax
  • Script include: D1imCatalogItemHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment