'Catalog Tasks 'related list, 'New' button should be visible only for Request management group.

ashok17
Tera Contributor

In the RITM backend form 'Catalog Tasks' related list, 'New' button should be visible only for Request management group.

 

Please suggest possible approaches for this.

 

Tried below script in list control but not works:

if (!parent.active) {
    if ( gs.getUser().isMemberOf('b0e4ae74975e9110902978ae2153af8a') ) {
        answer = true;
    }
    else{
     answer = false;
    }
}
1 ACCEPTED SOLUTION

With that new requirement, if you want admins to only see the New button if the RITM is active, then you can add that to the else if condition:

if (!parent.active) {
    answer = true; //hide the New button if the RITM is inactive
} else if (gs.getUser().isMemberOf('b0e4ae74975e9110902978ae2153af8a') || gs.hasRole('admin')) {
    answer = false; //do not hide the New button if the RITM is active, and the user is a member of the group OR has the admin role
} else {
     answer = true; //hide the New button if the user is not a member of the group and does not have the admin role
}

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

If you are using this script in the 'Omit new condition' field, as you should, be aware that returning an answer of true means that the button will be omitted/hidden.  So with your script the New button will only be hidden when the RITM is inactive and the user is a member of the group.  Given the description of your requirement, it sounds like what you want is:

if (!parent.active) {
    answer = true; //hide the New button if the RITM is inactive
} else if (gs.getUser().isMemberOf('b0e4ae74975e9110902978ae2153af8a') ) {
    answer = false; //do not hide the New button if the RITM is active and the user is a member of the group
} else {
     answer = true; //hide the New button if the user is not a member of the group
}

 

Thank you for response and below script works for my requirement but admin not able to see 'New ' button, only 'New' button visible only certain group members , please suggest.

 

if (!parent.active) {
    answer = true; //hide the New button if the RITM is inactive
} else if (gs.getUser().isMemberOf('22122b37c611228400f9ff91c857581d')) {
    answer = false; //do not hide the New button if the RITM is active and the user is a member of the group
} else {
    answer = true; //hide the New button if the user is not a member of the group
}

 

With that new requirement, if you want admins to only see the New button if the RITM is active, then you can add that to the else if condition:

if (!parent.active) {
    answer = true; //hide the New button if the RITM is inactive
} else if (gs.getUser().isMemberOf('b0e4ae74975e9110902978ae2153af8a') || gs.hasRole('admin')) {
    answer = false; //do not hide the New button if the RITM is active, and the user is a member of the group OR has the admin role
} else {
     answer = true; //hide the New button if the user is not a member of the group and does not have the admin role
}