Scoped access to user/session domain

jeremy_gardner
Tera Expert

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

5 REPLIES 5

Deepak Ingale1
Mega Sage

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();


}


5


Unfortunately this is for a store app, but thanks for the suggestion!


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


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