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

Action Filter based on WTGroup

SOLVED
Highlighted
Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Action Filter based on WTGroup

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

View solution in original post

6 REPLIES 6
Highlighted

Re: Action Filter based on WTGroup

DirectoryContextProvider contextProvider = WTContainerHelper.service
        .getExchangeContainer().getContextProvider();
WTGroup group = OrganizationServicesHelper.manager.getGroup(<GROUPENAME>, contextProvider);
Highlighted

Re: Action Filter based on WTGroup

Hello @bmr ,

 

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

Highlighted

Re: Action Filter based on WTGroup

Hello @bmr ,

 

I found a solution to get the group from one of your comments in the below mentioned article. 

 

https://community.ptc.com/t5/Windchill/How-to-get-the-group-names-of-the-user-who-has-logged-in-Need...

 

The only change I did is to iterate the enumeration and the filter is working now. Thanks for the response.

 

Regards,

Hari R

Highlighted

Re: Action Filter based on WTGroup

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

View solution in original post

Highlighted

Re: Action Filter based on WTGroup

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.

 

Highlighted

Re: Action Filter based on WTGroup

Hello @jmorton-2 ,

 

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

Announcements