Accessing the company field of a user using the g_user element

vivek4346
Mega Contributor

Hi all,

I am new to service now and have been exploring the platform. I wanted to know if there was a way to access a variable called 'company' present for every user, using the g_user method.

Regards,

Vivek

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Vivek,



Nothing OOTB at the client side. However at server side you can get the current logged in user's company sys_id as


gs.getUser().getCompanyID()


http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0



You can create a script include and return back the response at client side with the usage of GlideAjax. More info here.


http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0



View solution in original post

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

When you say variable? you have a variable referenced to sys_user table and from here you want to fetch the company?


Regards
Harish

Hi Harish,



Yes, each user from the sys_user table has a company.



Regards,


Vivek


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Vivek,



Nothing OOTB at the client side. However at server side you can get the current logged in user's company sys_id as


gs.getUser().getCompanyID()


http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0



You can create a script include and return back the response at client side with the usage of GlideAjax. More info here.


http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0