Using Groovy Scriptrunner, is it possible to make the following happen:
The DESCRIPTION field is locked when:
1. User is in PROJECT ROLE ABC
AND
2. Issue status is NOT Open
In other words, users in the project role should only be able to edit the Description field when the status is Open. Once it moves past open, the user can no longer edit the field.
Below are settings that I have tried but the DESCRIPTION field is not locking, regardless of the status. The behavior is mapped to all projects & issue types.
I also attempted to lock the DESCRIPTION field when the status is OPEN (regardless of the project role). This did not work - the add-on did not lock the field.
Hi Karrie,
The except condition is when you are in a transition screen, but I understand you care about the status of the issue. Therefore in your case your will need to add a servier side script that will look like
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.roles.ProjectRoleManager import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript import static com.atlassian.jira.issue.IssueFieldConstants.* @BaseScript FieldBehaviours fieldBehaviours def description = getFieldById(DESCRIPTION) def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager) def devProjectRole = projectRoleManager.getProjectRole("Developers") if (projectRoleManager.isUserInProjectRole(currentUser, devProjectRole, issueContext.getProjectObject()) && underlyingIssue?.status?.name != "Open") { description.setReadOnly(true) } else { description.setReadOnly(false) }
PS. That script checks tha name of the status and not the name of the status category, if the later is your case then use
underlyingIssue?.status?.statusCategory?.name != "Open"
Hope that does the trick.
Regards, Thanos
Thanks! I will give that a try today.
You mentioned that this is a server script, but I am not entirely sure where to save the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Under SCRIPT CONSOLE, I changed the project role from "Developer" to "Test" (it is a valid role) and got the following error message
Error: Cannot get property 'pid' on null object
java.lang.NullPointerException: Cannot get property 'pid' on null object at com.onresolve.jira.groovy.user.FormField.getFormValue(FormField.groovy:168) at com.onresolve.jira.groovy.user.FieldBehaviours.getIssueContext(FieldBehaviours.groovy:182) at Script12.run(Script12.groovy:15)
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.