- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 07:31 AM
Hi,
I have created a related list action in scoped app and is using the folowing code but window.location.href is not working. Can somebody give me the alternative code that I can use here?
function onClick() {
alert('This is a simple alert message!');
var a = window.location.href;
alert('newThis is a simple alert message!');
alert('abc'+a);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 08:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 07:44 AM
@MaharshiC Unfortunately, window.location.href is not available in the scoped application client script/UI action and there is simply no way to access it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 07:49 AM
Hi @Sandeep Rajput ,
Thanks for your reply. Can you give me the alternative code that I can use to get the current URL?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 07:51 AM - edited 02-19-2025 07:51 AM
@MaharshiC You can create a UI Script in the Global scope and call that UI Script from your scoped client script to fetch the window object. However, I will not recommend this as if your scoped app is meant to be distributed on the ServiceNow app store then the UI Script in the Global scope can't be packaged with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 08:04 AM
Hi @Sandeep Rajput ,
So what will be your suggestion then ? Any other alternative than to create the UI script in global scope?