
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2021 03:07 AM
I'm currently in the process of setting up Agent Workspace to allow users to work on Incidents. We have a number of custom client scripts that run on Incident that i need to configure to work correctly in workspace. Is there a way to determine which UI you are in? I know there is the GlideURI server-side api which i could use to pull apart the uri to determine i'm in workspace but was wondering if there is anything on the client-side i could use? window.location.href doesn't work in workspace either...
Solved! Go to Solution.
- Labels:
-
Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2021 03:15 AM
Hi,
you can use the view name i.e. workspace to make client scripts run on workspace
OR
you can check URL
if it contains 'now/agent/workspace' then it's workspace and not native UI
var url = top.location.href;
if(url.indexOf('now/agent/workspace')){
// workspace
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2021 04:07 AM
you can use the workaround I provided.
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 02:03 AM - edited 06-18-2024 05:00 AM
Recently have been working on this in regards to the SOW so figured it'd be worth updating on this in case people come across it.
You can get the view in a client sided script by getting g_form.getViewName();
Here's an example:
var view = g_form.getViewName();
if (view == "sow" || view = "sow_new_record") {
// Put necessary code here
}
However, at least for the SOW this was not reliable as not every table has a SOW specific view.
Therefor using top.location.href is more reliable at detecting the SOW or other modern workspaces.
Example:
var inSOW = false;
//check url for SOW
var url = top.location.href;
//indexOf returns a numeric value, -1 is not found
if (url.indexOf('/now/sow/') != -1) {
inSOW = true;
}
if (inSOW) {
//Put necessary code here
}
I hope this additional information is helpful to anyone!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2021 03:38 AM
Thank you for marking my response as helpful.
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 11:07 PM
There is a variable "g_aw" which is only present in the workspace env.
So
typeof g_aw !== "undefined" -> true in workspace
tyepof g_aw === "undefined" -> for platform/ native UI
Hope this helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 06:40 AM - edited 08-20-2024 01:40 AM
if (typeof g_aw != 'undefined') {
console.log('workspace');
} else {
console.log('not in a workspace');
}