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)
..
Solved! Go to Solution.
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
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