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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Translate the entire conversation x

Is it possible to make the Windchill custom menu visible only to specific groups?

YC_9410522
6-Contributor

Is it possible to make the Windchill custom menu visible only to specific groups?

Version: Windchill 12.1

 

Use Case: custom menu visible


Description:

Hello.

 

I added a custom menu to the Actions menu, and I want it to be visible only to a specific group.

Is there any reference material I can use? Thank you.

 

f0cb2a5c-cf6e-4c04-af52-846a86b4a60e.png

 

ACCEPTED SOLUTION

Accepted Solutions

in customactions.xml file you can add a filter

<action name="UpdateCalculatedValues">

<command url="/netmarkets/jsp/UpdateCalculatedValues.jsp" windowType="popup"/>

<includeFilter name="ActionFilter"/>

</action>


and then in filter class you can add your logic :
public class ActionFilter extends DefaultSimpleValidationFilter {
//in prevalidate action add below logic (Please not this is not complete code, these are just snippets which may help you)

/*

if(componentID.equalsIgnoreCase(Constants.UPDATE_CALCULATED_VALUES))

{

// enable action if user has 'Modify'access.

groupName = "Sample Group";

WTPrincipal sessionUser = SessionHelper.manager.getPrincipal();

WTGroup group = getGroup(groupName);

boolean isMember = isUserGroupMember(group, sessionUser);

boolean hasModifyAccess = AccessControlHelper.manager.hasAccess(user, part,AccessPermission.MODIFY);

if(hasModifyAccess && isMember ){

validationStatus = UIValidationStatus.ENABLED;

}

}

 */

public static WTGroup getGroup(String groupName) {

WTGroup group = null;

try {

QuerySpec querySpec = new QuerySpec(WTGroup.class);

querySpec.appendWhere(new SearchCondition(WTGroup.class, WTGroup.NAME,SearchCondition.EQUAL, groupName), new int[] { 0 });

QueryResult queryResult = PersistenceHelper.manager.find((StatementSpec)querySpec);

group = (queryResult!=null && queryResult.hasMoreElements()) ? (WTGroup) queryResult.nextElement() : null;

 

}catch(Exception e) {

e.printStackTrace();

}

return group;

}

 

public static boolean isUserGroupMember(WTGroup group, WTPrincipal sessionUser) throws WTException {

boolean retVal = false;

if(group!=null) {

if(group.isMember(sessionUser)){

retVal = true;

}

}

return retVal;

 

}

}

View solution in original post

3 REPLIES 3
Fadel
23-Emerald I
(To:YC_9410522)

in customactions.xml file you can add a filter

<action name="UpdateCalculatedValues">

<command url="/netmarkets/jsp/UpdateCalculatedValues.jsp" windowType="popup"/>

<includeFilter name="ActionFilter"/>

</action>


and then in filter class you can add your logic :
public class ActionFilter extends DefaultSimpleValidationFilter {
//in prevalidate action add below logic (Please not this is not complete code, these are just snippets which may help you)

/*

if(componentID.equalsIgnoreCase(Constants.UPDATE_CALCULATED_VALUES))

{

// enable action if user has 'Modify'access.

groupName = "Sample Group";

WTPrincipal sessionUser = SessionHelper.manager.getPrincipal();

WTGroup group = getGroup(groupName);

boolean isMember = isUserGroupMember(group, sessionUser);

boolean hasModifyAccess = AccessControlHelper.manager.hasAccess(user, part,AccessPermission.MODIFY);

if(hasModifyAccess && isMember ){

validationStatus = UIValidationStatus.ENABLED;

}

}

 */

public static WTGroup getGroup(String groupName) {

WTGroup group = null;

try {

QuerySpec querySpec = new QuerySpec(WTGroup.class);

querySpec.appendWhere(new SearchCondition(WTGroup.class, WTGroup.NAME,SearchCondition.EQUAL, groupName), new int[] { 0 });

QueryResult queryResult = PersistenceHelper.manager.find((StatementSpec)querySpec);

group = (queryResult!=null && queryResult.hasMoreElements()) ? (WTGroup) queryResult.nextElement() : null;

 

}catch(Exception e) {

e.printStackTrace();

}

return group;

}

 

public static boolean isUserGroupMember(WTGroup group, WTPrincipal sessionUser) throws WTException {

boolean retVal = false;

if(group!=null) {

if(group.isMember(sessionUser)){

retVal = true;

}

}

return retVal;

 

}

}

thanks it's working!!

Announcements
Top Tags