- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2025 10:03 PM
I'm trying to call a UI script by clicking a button I've implemented in the portal.
However, even though I've implemented a script that works on the platform, it doesn't work from the portal...
Is it possible to use UI scripts on the portal?
I'd like to know how.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2025 05:08 AM
Hello @bonsai
After following the steps in my previous reply, you can directly call the UI Script function from the client controller.
For example, if your UI Script contains:
function showAlert() {
alert("test");
}
Once you add this UI script as a dependency in the widget’s related list, you can simply call the function in the client controller:
For example:
api.controller = function($scope) {
/* widget controller */
var c = this;
showAlert();
};
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2025 10:16 PM
Hi Bonsai,
Please provide the script you are referring to. That way the community can assess whether the script is appropriate for the portal.
Some things to keep in mind:
Not everything that is available to a script on the platform (server-side), will be available to a script on the Portal (client-side). An example of this is the GlideSystem.
For a script on the portal to have access to the "server side" features, you will need to call a server side script by means of a GlideAjax call.
Please refer to the Product Documentation and ask here if you have any more questions:
https://www.servicenow.com/docs/csh?topicname=c_GlideAjaxAPI.html&version=latest
Regards,
Will.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2025 10:53 PM
This is the widget configuration.
The UI script is called in the client controller.
This is the UI script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2025 11:18 PM
You will need to add the UI Script as a dependency.
Please refer to the following Product Documentation:
https://www.servicenow.com/docs/csh?topicname=widget-dependencies.html&version=latest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2025 11:28 PM
P.S.
To provide more clarity, you create the dependency in the related lists when viewing your widget page (test_button).
Once the dependency is created, you can go to the platform, navigate to "Service Portal > Dependencies" and open your dependency.
In the JS Includes related list, add a new record, and link it to your UI Script. You'll see that the "Source" supports UI Script.
I hope that helps!