Client Script vs UI Policy Explained
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 08:21 PM
Sometimes we get confused between Client Script and UI Policy, therefore I try to explain in simple terms
1. Scripting Requirement: Client Script as the name suggests does require a script and you can not do anything without scripting knowledge, however UI Policy can fullfill a lot of requirements without scripting.
Example - You have an incident form and you want to make sure that if the ticket calling user is a VIP, the caller ID field flashes and an ICON is displayed next to it, in this case you would write a script to do so
On the other hand if the incident is set to resolved, you ensure that CI field is set to mandatory to ensure no blank CI ticket is submitted, for this you can simply use UI Actions within UI Policy without writing code.
2. Execution Order : UI Policy always executes after the client script.
Client Scripts are executed in the user's browser either before the form loads or when a field changes, allowing for dynamic updates to the form's behavior based on specific conditions. These scripts are triggered by events like onChange, onLoad, or onSubmit. In contrast, UI Policies manage UI elements, such as setting fields to be visible, mandatory, or read-only. They execute after the form has loaded, and their actions are triggered when their conditions are met.
Client Scripts run before UI Policies because they need to react immediately to user actions, such as field changes or form loading. This allows them to customize the form's behavior in real time. After Client Scripts have set the necessary data or state, UI Policies adjust the display and state of the UI elements accordingly.
Example in an incident form, if you need to display an alert when the form is loaded, you will use client script, but if you want to make some field mandatory after a field value changes, you would need client script.
3. OnChange in Client script allows the client script to execute on a particular field value, whereas UI policy can be applied to multiple fields within the same table.
4. Client script has access to previous value of a particular field in order to make a comparision, for example in Client Script you can compare the old value of the Incident state to the new value of incident state and take an action using OnChange function, this does not exist in UI Policy.
5. Both UI Policy and Client Script are client side actions, i.e. they are executed on user's browser.
Best regards
Surya Prakash Garg
Connect me on Linked In
https://www.linkedin.com/in/spgarg/
- 2,482 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 09:33 AM
Great explainer, thanks!~