- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 02:57 AM
Hi Guys,
I am trying to retrieve the current session's Domain using a server side scoped application script. Using the 'gs.getUser().getDomainID() ' function gives the following error-
'Cannot find function getDomainID in object com.glide.script.fencing.ScopedUser'
Is there any other way to retrieve the current domain using a scoped application script without explicitly calling a globally scoped script?
Any help would be highly appreciated.
Thanks,
Aditya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 11:28 AM
Hi Aditya,
The session/user getDomainID() methods are not exposed to scope currently. As a workaround, I'd suggest creating a Script Include with a method you can call that will create a domain-separated record and just read the domain off of it. Like this:
var DomainInfo = Class.create();
DomainInfo.prototype = {
initialize: function() {
},
getCurrentDomain : function() {
var throwAwayRecord = new GlideRecord("sys_user");
throwAwayRecord.newRecord();
return throwAwayRecord.getValue("sys_domain");
},
type: 'DomainInfo'
};
Then when you want to get the domain, you call your Script Include:
var currentDomain = new DomainInfo().getCurrentDomain();
This assumes that the sys_user table is domain-separated. I'd suggest using a domain-separated table which doesn't have Number Maintenance or other auto-incrementing stuff, since we are deliberately initializing a full record, but never saving it.
Thanks,
Cory Seering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 02:56 AM
Hi Rajesh,
Do you know name of the Glide API that needs to be used in the 'target name' field for allowing access to these domain support functions?
Thanks,
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 05:36 AM
Hello Aditya,
Target Name | The name of the table, script include, or script object being requested |
It may be your global table or script include, script object
Example : Table : incident, problem
Script include: your script include.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 11:28 AM
Hi Aditya,
The session/user getDomainID() methods are not exposed to scope currently. As a workaround, I'd suggest creating a Script Include with a method you can call that will create a domain-separated record and just read the domain off of it. Like this:
var DomainInfo = Class.create();
DomainInfo.prototype = {
initialize: function() {
},
getCurrentDomain : function() {
var throwAwayRecord = new GlideRecord("sys_user");
throwAwayRecord.newRecord();
return throwAwayRecord.getValue("sys_domain");
},
type: 'DomainInfo'
};
Then when you want to get the domain, you call your Script Include:
var currentDomain = new DomainInfo().getCurrentDomain();
This assumes that the sys_user table is domain-separated. I'd suggest using a domain-separated table which doesn't have Number Maintenance or other auto-incrementing stuff, since we are deliberately initializing a full record, but never saving it.
Thanks,
Cory Seering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 02:03 AM
Hi coryseering.
Initializing the record without saving it always returns the domain as global irrespective of the current session's domain.
As a work around, I created a custom domain separated table within my application scope, and used a scoped script include to create a record in the table, return the domain, and then subsequently delete the record.
Thanks a lot for your help, really appreciate it.
Regards,
Aditya