ServiceNow UI Script | ServiceNow Call UI Script from Client Script | ServiceNow UI Script Demo
TechnoMonk
Hi Folks, In this video we will discuss on ServiceNOw UI Script . We will check how we can call UI Script from Clientscript ServiceNow. I scripts provide a way to package client-side JavaScript into a reusable form, similar to how script includes store server-side JavaScript. Administrators can create UI scripts and run them from client scripts and other client-side script objects and from HTML code.
UI scripts are not supported for mobile.
Global UI scripts You can create a UI script and designate it as global, which makes the script available on any form in the system. You cannot create a global UI script in a scoped application.
You can mark a UI script as Global to make it available on any form in the system. For example, you can create a UI script that has a function helloWorld(), and has the Global field checked:
function helloWorld() { alert('Hi'); } After you create this global UI script, you can call the helloWorld() function from any client script or UI policy you write.
Create a UI script Create a UI script to define reusable client-side JavaScript code.
To create UI scripts, navigate to System UI - UI Scripts and create or edit a record (see table for field descriptions). Run UI scripts Follow these guidelines when running UI scripts.
Run a UI script from a form To run a UI script on a form, create a formatter. In the associated UI macro, include a g:requires tag and specify the name= parameter as the name of the UI script followed by the .jsdbx extension. Add the formatter on the form view.
This code ensures that the definitions and results of the UI script are immediately available in the browser. Create and Use a UI Script In this exercise, you will add a UI Script to the Angular App application. The UI Script will define the application's controller and add three properties to the application object ($scope). The UI Script is included in the application's UI Page.
Create a UI Script Create a UI Script.
In Studio, click the Create Application File link. In the Filter... field, enter the text UI OR select Client Development from the categories in the left hand pane. Select UI Script in the middle pane as the file type, then click the Create button. Configure the UI Script:
Script Name: angular_app_client_logic
API Name: (This value is automatically populated)
Description: Client-side logic for Angular App.
Examine the pseudo-code for the UI Script you will write:
Create an angular module called angularapp that has no dependencies
Create a controller for the app
Add a string property and a number property to the controller
Create a function that sets the myVar and i property values
Display an alert that says how many times the text has been cleared by the user
43650107 Bytes