ServiceNow Blog 03: Client side scripting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 06:27 AM
1) Ajax client scripting:
- The GlideAjax class enables a client script to call server-side code in a script include.
- To use GlideAjax in a client script, follow these general steps.
- Create a GlideAjax instance by calling the GlideAjax constructor. As the argument to the constructor, specify the name of the script include class that contains the method you want to call.
- Call the addParam method with the sysparm_name parameter and the name of the script-include method you want to call.
- (Optional) Call the addParam method one or more times to provide the script-include code with other parameters it needs.
- Execute the server-side code by calling getXML().
Note: getXML() is the preferred method for executing the code, because it is asynchronous and does not hold up the execution of other client code. Another method, getXMLWait(), is also available but is not recommended. Using getXMLWait() ensures the order of execution, but can cause the application to seem unresponsive, significantly degrading the user experience of any application that uses it. getXMLWait() is not available to scoped applications.
2) UI Policy:
- What is UI Policy: UI policy is used to change the behavior of information on the form.
- Runs at client side.
- It is primarily used to make fields read-only, visible, and mandatory on the form.
- No scripting is required.
- Advanced changes required scripting.
3) Service catalog UI Policy:
- UI policies can be used to define custom process flows for tasks.
- Catalog UI policies control the behavior of catalog item forms when presented to your users.
- Catalog UI policies can be applied to a catalog item or a variable set.
- UI policies are useful when applied to service catalog items.
- Keep the following points in mind when creating service catalog UI policies:
- A catalog UI policy applies to either a specific catalog item or any item that uses a specific variable set.
- A catalog UI policy can only contain and reference variables that are defined for the catalog item or variable set.
- Like UI policy conditions, the variables in a service catalog UI policy condition must be visible (even if hidden by UI policy or read-only) on the form for the condition to be tested. Also, ensure that the variables have names.
- Limited UI policy functionality applies to following variables:
- The Mandatory and Read Only policy do not apply to the following variable types: Break, Container Split, Container End, UI Macro, UI Macro with Label, Label, UI Page.
- The Set visible policy does not apply to the following variable types: Break, Container Split, Container End.
Service catalog UI policies are applied to variables and variable sets of catalog items ordered in the service catalog. Policies can also be applied when the variables are present in a Requested Item or Catalog Task form.
4)UI Actions: User interface
- Add buttons links, and context menu items on form & lists, making the UI more interactive, customizable, and specific to user activities.
- A creating problem button to an existing incident form is an example of UI Action.
- UI Actions include:
- Form button
- Form context menu items (right-click the header)
- Form links (Related links in a form)
- List buttons
- List context menu item (right-click a record)
- List choices (at the bottom of the list)
- List links (related links at the bottom of the list).
- 252 Views