Posts

Showing posts with the label form validation

Client Script vs UI Policy in ServiceNow

Image
  When to Use Each (and Avoid Performance Problems) Many ServiceNow beginners ask: Should I use Client Script or UI Policy? Both can: make fields mandatory hide/show fields set read-only control form behavior But choosing the wrong one creates performance issues and difficult maintenance. The Main Difference UI Policy → Configuration based behavior (no coding) Client Script → Logic based behavior (requires scripting) What UI Policy Does 4 UI Policy is used when behavior depends on simple conditions. Example: If Category = Hardware → show Serial Number field No scripting required. Advantages Faster Cleaner Easy to maintain Non-developers can manage What Client Script Does 4 Client Script is used when logic is complex. Example: Validate employee ID format Check value dynamically Calculate field value Requires JavaScript. Types of Client Scripts onLoad onChange onSubmit onCellEdit Used for dynamic validation and processing. Practical Comparison Requirement Use UI Policy Use Client Scr...