How to call UI script in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 06:12 PM
I created a simple ui script, as mentioned below. How can I call this from client script?
function displaytitle()
{
var a= g_form.getValue('number');
var b= g_form.getValue('short_description');
if(a && b)
{
top.document.title= a +'-'+ b;
}
else
{
alert('hello');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 06:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 06:56 PM
Hi Sunny,
You can mark a UI script as Global to make it available on any form in the system.
After you create this global UI script, you can call the function from any client script or UI policy you write.
In your case, just make the UI script as global and call displaytitle() in all of the client scripts.
Refer global UI sciprts for more :
http://wiki.servicenow.com/index.php?title=UI_Scripts#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 06:57 PM
Hi Sunny,
You can call the UI Script like below. Lets say your UI Script name is myUIScript.
var validateFields = new myUIScript();
validateFields.getDateFields(g_form);
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 07:08 PM