{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":2199,"path":"application-development/form-logic.md","title":"Form logic","bundle":null,"doc_type":null,"release":"australia","body":"\n# Form logic\n\nControlling what users see when they visit a form can increase productivity and responsiveness. For example, users should only see fields that are useful to them. Users may only need to see certain fields based on what is configured on the form. Apply form logic to control what is visible, read-only, and mandatory on a form.\n\n## Agentic AI\n\nCreate applications with help from agentic AI. For more information, see [Agentic development on the ServiceNow AI Platform](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/use-ai-capabilities-in-custom-apps.md).\n\n## Determine when to control user access\n\nThe following question will help direct you to the right decision for when to control user access to information: Is this a suggestion or enforcement? A suggestion makes the form easier to complete whereas enforcement forces the user to do something in order to complete the form.\n\nUI policies are useful for conditional suggestions like showing and hiding fields or adding field messages based on another field’s value, while Data policies and Business Rules are better suited for doing conditional enforcement like making a field mandatory.\n\nThe best user experience is to utilize both suggestion and enforcement together.\n\nFor more information, see the [UI Policy](https://developer.servicenow.com/dev.do#!/learn/courses/paris/app_store_learnv2_scripting_paris_scripting_in_servicenow/app_store_learnv2_scripting_paris_client_side_scripting/app_store_learnv2_scripting_paris_ui_policies) article in the Client-side Scripting Module.\n\nBuild UI Policies and Data Policies to handle client-side activities before scripting any client-side logic. Use of Client Scripts to validate user input and provide feedback while the user is completing the form.\n\nSome general practices for client scripting are:\n\n-   Optimize for performance by using asynchronous GlideAjaxover client-side GlideRecordor multiple getReference\\(\\)calls.\n-   Keep the isLoadingcheck in onChangeclient scripts.\n-   Keep the newValuecheck and add a newValue != oldValuecheck.\n-   Use all client-side scripts possible before making a server call with GlideAjax. Server roundtrips can impact performance.\n\nSome client scripting practices to avoid are:\n\n-   Global Client Scripts or Global UI Scripts: Global scripts will run on every page load and introduce browser load delay.\n-   DOM Manipulation: Using document object model manipulation against default UI elements introduces upgrade risk and maintainability issues. The exception is using DOM manipulation against the DOM in pages authored in the same scoped application, like UI Pages or Service Portal widgets.\n\n**Parent Topic:**[Build form and business logic](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/build-form-and-business-logic.md)\n\n"}}