We have scriptrunner. I'm using a Behaviour to lock a field for editing. There is an exception. If a user is a part of a specific group, the field can be edited. If the user is not in that group, the field is locked.
Is there a way to show some helper text to a user not in the group that the field is locked because they're not in the group?
This code should do it for you:
import com.atlassian.jira.component.ComponentAccessor;
final String permittedGroup = "GROUP";
final String protectedField = "Field";
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def groupManager = ComponentAccessor.getGroupManager();
def valid = groupManager.getGroupsForUser(currentUser).find {it.getName() == permittedGroup}
def field = getFieldByName(protectedField);
if (valid == null) {
field.setDescription("Only members of $permittedGroup can edit this field");
field.setReadOnly(true);
} else {
field.setDescription("Please edit this field");
field.setReadOnly(false);
}
That did it. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.