Skip to main content
Jun 23, 2020 5:12 PM UTC
Solved

Action Filter based on WTGroup

Hello,

 

I want to introduce a filter for an action which should restrict a certain set of users.

 

The solution I thought was to associate the set of users to a group, created under Organization context, and the filter will validate if the current user belongs to the said group and if so the action will be hidden.

 

I used the below mentioned API to find the group based on the user but it is not giving me any output i.e. enumeration is empty

Enumeration enumeration = OrganizationServicesHelper.manager.parentGroups(validationCriteria.getUser().getPrincipal(),false);

 

Please provide an alternative way or an API I can implement.

 

Thanks and Regards,

Hari R

Jun 29, 2020 7:52 PM UTC

I'm sorry, I sent you the code for Site WTGroups and not for the organisation.

 

WTOrganization org = OrganizationHelper.getOrganizationByName("<ORGANISATION_NAME>");

 OrgContainer orgContainer = WTContainerHelper.service.getOrgContainer(org);
 PrincipalSpec principalSpec = new PrincipalSpec(WTContainerRef.newWTContainerRef(orgContainer), WTGroup.class);
 principalSpec.setPerformLookup(false);
 principalSpec.setIncludeAllServices(true);
 DirectoryContextProvider[] directoryContextProviders = WTContainerHelper.service.getPublicContextProviders(principalSpec);

 WTGroup foundGroup = OrganizationServicesHelper.manager.getGroup("<GROUP_NAME>", directoryContextProviders[0]);
 log.debug("foundGroup = {}", foundGroup);

8 replies

Jun 23, 2020 6:59 PM UTC
DirectoryContextProvider contextProvider = WTContainerHelper.service
 .getExchangeContainer().getContextProvider();
WTGroup group = OrganizationServicesHelper.manager.getGroup(<GROUPENAME>, contextProvider);
hsha1102Author
Jun 27, 2020 7:28 AM UTC

Hello @BjoernRueegg ,

 

Thank you for the response.

 

But the API that you have provided is not working, group is coming as null.

 

Is there any other way to get the group from Org context ?

 

Regards,

Hari R

Jun 29, 2020 6:14 PM UTC

Why don't you just use Profiles?

You can make a Profile in Windchill that restricts the actions you want, then assign users to that Profile. No coding required.

 

hsha1102Author
Jun 30, 2020 4:40 PM UTC

Hello @joe_morton ,

 

Since I am trying to hide a custom action, it was not visible in Profiles page. Hence I chose to introduce filter for the action.

 

Thanks and Regards,

Hari R