what is ui script in servicenow ?

elizabeth keen
Giga Contributor

can any one please tell me about ui script in servicenow. 

1 ACCEPTED SOLUTION

shubham jagtap
Tera Guru

Hi,

UI scripts

UI 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.

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).
UI scripts
FieldDescription
Script NameName of the UI script. Ensure the name is unique on your system.
API NameThe API name of the UI script, including the scope and script name (for example, x_custom_app.HelloWorld).
ApplicationApplication that contains the UI script.
ActiveIndicator of whether the UI script is active. Only active UI scripts can run.
Global

Indicator of whether the script loads on every page in the system.

Note: Use caution when creating global UI scripts because they can impact performance. You cannot create a global UI script in a scoped application.
DescriptionSummary of the purpose of the script.
ScriptClient-side script to run when called from other scripts.
you can refer below links: https://developer.servicenow.com/app.do#!/training/article/app_store_learnv2_angularjs_jakarta_introduction_to_angularjs_in_servicenow/app_store_learnv2_angularjs_jakarta_ui_scripts?v=jakarta https://developer.servicenow.com/app.do#!/lp/new_to_servicenow/app_store_learnv2_angularjs_kingston_using_ui_scripts?v=kingston https://docs.servicenow.com/bundle/london-application-development/page/script/client-scripts/concept/c_UIScripts.html https://community.servicenow.com/community?id=community_question&sys_id=4705cf2ddbd8dbc01dcaf3231f96199d https://community.servicenow.com/community?id=community_question&sys_id=9c6e0321dbdcdbc01dcaf3231f961928 https://www.youtube.com/results?search_query=ui+scripts+in+servicenow After going throw this please mark it as correct/helpfull. Thank you.

View solution in original post

3 REPLIES 3

Alikutty A
Tera Sage

Hi,

UI scripts provide a way to group client-side JavaScript into a reusable content, 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 as a reusable component.

You can get more details in here: https://docs.servicenow.com/bundle/madrid-application-development/page/script/client-scripts/concept/c_UIScripts.html

Thanks!

shubham jagtap
Tera Guru

Hi,

UI scripts

UI 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.

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).
UI scripts
FieldDescription
Script NameName of the UI script. Ensure the name is unique on your system.
API NameThe API name of the UI script, including the scope and script name (for example, x_custom_app.HelloWorld).
ApplicationApplication that contains the UI script.
ActiveIndicator of whether the UI script is active. Only active UI scripts can run.
Global

Indicator of whether the script loads on every page in the system.

Note: Use caution when creating global UI scripts because they can impact performance. You cannot create a global UI script in a scoped application.
DescriptionSummary of the purpose of the script.
ScriptClient-side script to run when called from other scripts.
you can refer below links: https://developer.servicenow.com/app.do#!/training/article/app_store_learnv2_angularjs_jakarta_introduction_to_angularjs_in_servicenow/app_store_learnv2_angularjs_jakarta_ui_scripts?v=jakarta https://developer.servicenow.com/app.do#!/lp/new_to_servicenow/app_store_learnv2_angularjs_kingston_using_ui_scripts?v=kingston https://docs.servicenow.com/bundle/london-application-development/page/script/client-scripts/concept/c_UIScripts.html https://community.servicenow.com/community?id=community_question&sys_id=4705cf2ddbd8dbc01dcaf3231f96199d https://community.servicenow.com/community?id=community_question&sys_id=9c6e0321dbdcdbc01dcaf3231f961928 https://www.youtube.com/results?search_query=ui+scripts+in+servicenow After going throw this please mark it as correct/helpfull. Thank you.

vibha13
Kilo Contributor

how to stop alert function in global UI script. It is on load and not allowing me to log in to my instance.