Get domain of current user

Rj27
Mega Guru

Hi There,

I want to fetch the domain of current user in my script include.

i am using ...
var domain = gs.getUser().getDomainID();
gs.print('Domain ID is =='+domain )

This is giving me the domain of the user from domain picker. but i want to get the value which is there in the user table.
can  i not get the value directly without gliderecording the user table?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@Rj27 

Just to inform gs.getUser().getRecord().getValue('fieldName') won't work in scoped application

It would work in global scope.

For Global Scope:

gs.info('Domain ID is ==' + gs.getUser().getRecord().getValue('sys_domain'));

For Custom scope

better you query sys_user table for that user and get the domain value

var user = new GlideRecord('sys_user');

user.get(gs.getUserID());

gs.info('Domain ID is ==' + user.sys_domain);

Regards
Ankur

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron

@Rj27 

Just to inform gs.getUser().getRecord().getValue('fieldName') won't work in scoped application

It would work in global scope.

For Global Scope:

gs.info('Domain ID is ==' + gs.getUser().getRecord().getValue('sys_domain'));

For Custom scope

better you query sys_user table for that user and get the domain value

var user = new GlideRecord('sys_user');

user.get(gs.getUserID());

gs.info('Domain ID is ==' + user.sys_domain);

Regards
Ankur

Hi Ankur, 

if gs.getUser().getRecord.getValue() doesnot work in scope app then it seems gliderecording is the only option left.

Thanks for the response!

 

You are welcome.

Regards