Action Filter based on WTGroup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
-
API
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
DirectoryContextProvider contextProvider = WTContainerHelper.service
.getExchangeContainer().getContextProvider();
WTGroup group = OrganizationServicesHelper.manager.getGroup(<GROUPENAME>, contextProvider);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
