Skip to main content
4-Participant
March 13, 2023
Solved

Retrieving associated user groups and roles

  • March 13, 2023
  • 2 replies
  • 1384 views

How to retrieve all roles/groups a user is associated with - Thingworx. 

Best answer by Constantine
// For the current user:
let myGroups = Resources["CurrentSessionInfo"].GetCurrentUserGroups();

// For user "alice":
let aliceGroups = Users["alice"].GetGroups();

2 replies

22-Sapphire I
March 13, 2023

I believe if you are in the context of 'current user' there is a GetGroups (Something like CurrentSession functions)

and I think the User object itself also supports something like that, but you may need recursion if not 'current user'

I know at one point there were some upgrades to the security mapping services, and there might be some other OOTB service now that can retrieve this, I unfortunately forget which services were added for that. Maybe start by checking here:

https://support.ptc.com/help/thingworx/platform/r9/en/index.html#page/ThingWorx/Help/Composer/Security/Users/AccessReports.html#

 

18-Opal
March 15, 2023
// For the current user:
let myGroups = Resources["CurrentSessionInfo"].GetCurrentUserGroups();

// For user "alice":
let aliceGroups = Users["alice"].GetGroups();