Scoped access to user/session domain

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 05:28 PM
Has anybody come up with a work-around to getting a user's domain within their session? Slightly different than getting the domain off their User > Company > Domain record, since certain users can switch domains. Looking for a scoped version of gs.getUser().getDomainID().
I liked coryseering's suggestion in this discussion: gs.getUser().getDomainID() not working in scoped application scripts, however it requires inserting a record to set the domain (as mentioned in the last post). I can make that work, but was hoping there's some other magic I'm overlooking.
Thoughts?
Thanks!
Jeremy
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 08:43 PM
Hi Jeremy,
If you are not working for an app which is going to get published on store or if you dont want to distribute it for customer, I would say you can configure a script include in global scope, and make script include "Accessible from all other scope" .This script include can have a function which will return the user session then. You can access this script include from your scoped app since it is "accessible from other scopes"
u_getUserSessionDomain : function() {
return gs.getUser().getDomainID();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 08:55 PM
5
Unfortunately this is for a store app, but thanks for the suggestion!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 08:59 PM
You can then just follow what Cory has suggested.
I would check if just initializing the record object for inserting will give me the domain id without me to insert the record actually in domain separated table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 09:07 PM
Yep, already tried that. If you only use initialize() or newRecord() it defaults to "global". You have to insert the record to apply the session domain.
Thanks!
Jeremy