0

How can i get below details of loggedin user via Rest API from servicenow?

1.Userprofile informations
2.Organization details
Priya
  • 29
  • 2
  • 8

1 Answers1

0

gs.getUser() has all the information:

gs.getUser().getFullName()
gs.getUser().getDepartmentID();
gs.getUser().getCompanyID();
georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • @georgeawg and Naveen how to use the above function in REST API call. For eg: Similar to following query , https://instance.service-now.com/api/now/table/sys_user?sysparm_query=sys_id=javascript:gs.getUserID() i need to form for gs.getUser() and the others. – Priya Sep 09 '19 at 06:31
  • Go to Scripted REST APIs - in the respective method script add these and check. – Naveen Reddy Sep 09 '19 at 08:30
  • Could you please suggest with normal REST API.Because we are not going to use scripted REST API. – Priya Sep 09 '19 at 09:32
  • GET http://instance.service-now.com/api/now/ui/user/current_user . will get the user_sys_id and user_name etc. Using this you can get further details - GET http://localhost:8080/api/now/table/sys_user?sysparm_limit=1&sys_id='replace from above' – Naveen Reddy Sep 09 '19 at 11:00
  • With the above api i am able to get user details.Please suggest how to find under which organization the user belongs to?. – Priya Sep 09 '19 at 12:10
  • You mean department. All information is there in the second get call. – Naveen Reddy Sep 09 '19 at 17:35
  • No.I need the Organization ID. Organization ID is the account level identifier among users. – Priya Sep 10 '19 at 06:24
  • I only see company attribute for the user. No other organisation related information – Naveen Reddy Sep 10 '19 at 08:50