Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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
Solved! Go to Solution.
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);
DirectoryContextProvider contextProvider = WTContainerHelper.service
.getExchangeContainer().getContextProvider();
WTGroup group = OrganizationServicesHelper.manager.getGroup(<GROUPENAME>, contextProvider);
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
Hello @BjoernRueegg ,
I found a solution to get the group from one of your comments in the below mentioned article.
The only change I did is to iterate the enumeration and the filter is working now. Thanks for the response.
Regards,
Hari R
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);
how do we do this in expression i get this error
WfExpression_11.java:76: error: cannot find symbol
wt.org.WTGroup wgroup = OrganizationServicesHelper.getOrganizationByName("<YONETICI-TEST>");
^
symbol: variable OrganizationServicesHelper
location: class WfExpression_11
Note: WfExpression_11.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
Hi @smcvr
The error tells you that something is missing.
You should use some IDE to create a code. (NetBeans, Eclipse, InteliJ) You could have found that you use wrong helper
the class OrganizationServicesHelper do not contains method getOrganizationByName
the method you used exists just in>
OrganizationHelper.getOrganizationByName(organizationName);
PetrH
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.
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