cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

WTGroup API removeMember(wtuser) removes user from all the group

ND_102012
5-Regular Member

WTGroup API removeMember(wtuser) removes user from all the group

 

Hello Experts,

I want to remove the user from groups using API .. license groups (e.g. "PTC Creo Data Management and Visualization License") & user created groups (e.g. "Advanced Viewing users") which are in turn added in license group by admin. 

 

Problem statement: I am using below API to get the groups in which user is member, but it is pulling the pseudo groups as well, like output I have provided below.

 

WTGroup.removeMember(wtUser), Windchill goes and delete all assigned groups and as well as pseduo groups associated to WTUser object. Which might lead to other issues for user.

 

What is best possible way to remove the user from group which are visible in UI (without removing from pseudo groups)? Does anyone has code snippet which I can reuse?

 

API:

Enumeration<WTPrincipalReference> groups = OrganizationServicesHelper.manager.parentGroups(wtUser);

 

OUTPUT:
..
*PRINT getPrincipal .getName() output* PRODUCT MANAGER
*PRINT principalRef.getPrincipalStatusDetails() output* Product Manager (Product - TEST_PRODUCT)

*PRINT getPrincipal .getName() output* PTC PDMLink Module License
*PRINT principalRef.getPrincipalStatusDetails() output* PTC PDMLink Module License (Site)
..

 

1 ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire I
(To:ND_102012)

HI @ND_102012 

Yes the API WTGroup.removeMember(wtUser); removes user from all groups because you do not specify from what group user should be removed

 

so first you need to search for the group that is WTGroup type and then call te function on that group

so it should be like following code

 

 

WTGroup groupVariable = searchGroup("GROUP NAME"); //searchGroup is just example of an external function
groupVariable.removeMember(wtUser);

 

 

hope this can help

 

PetrH

View solution in original post

1 REPLY 1
HelesicPetr
22-Sapphire I
(To:ND_102012)

HI @ND_102012 

Yes the API WTGroup.removeMember(wtUser); removes user from all groups because you do not specify from what group user should be removed

 

so first you need to search for the group that is WTGroup type and then call te function on that group

so it should be like following code

 

 

WTGroup groupVariable = searchGroup("GROUP NAME"); //searchGroup is just example of an external function
groupVariable.removeMember(wtUser);

 

 

hope this can help

 

PetrH

Top Tags