Skip to main content
11-Garnet
June 23, 2020
Solved

Action Filter based on WTGroup

  • June 23, 2020
  • 2 replies
  • 3613 views

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

Best answer by BjoernRueegg

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);

2 replies

17-Peridot
June 23, 2020
DirectoryContextProvider contextProvider = WTContainerHelper.service
 .getExchangeContainer().getContextProvider();
WTGroup group = OrganizationServicesHelper.manager.getGroup(<GROUPENAME>, contextProvider);
hsha110211-GarnetAuthor
11-Garnet
June 27, 2020

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

joe_morton
18-Opal
18-Opal
June 29, 2020

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.

 

hsha110211-GarnetAuthor
11-Garnet
June 30, 2020

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