在behavior中创建 Initialiser
代码
import com.atlassian.jira.component.ComponentAccessor // Get the current user def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def issue def status def user1 def user2 if(underlyingIssue){ // If the issue key exists (NOT a CREATE screen) // Get the issue key issue = ComponentAccessor.issueManager.getIssueObject(underlyingIssue.id) // Get the issue's status status = issue.status.name // Get the "开发值守人"、"产品值守人"、"测试值守人"、"发布值守人" fields and the values def user1Field = ComponentAccessor.customFieldManager.customFieldObjects.findByName("开发值守人") user1 = issue.getCustomFieldValue(user1Field) def user2Field = ComponentAccessor.customFieldManager.customFieldObjects.findByName("产品值守人") user2 = issue.getCustomFieldValue(user2Field) } // Get the "计划开始发布时间" field by name def dateTimePicker = getFieldByName("计划开始发布时间") // Set the "计划开始发布时间" field read-only for ALL screens dateTimePicker.setReadOnly(true) // Set the "计划开始发布时间" field editable only if the below conditions met: if(getActionName() == "Create"){ // If current action is Create Screen dateTimePicker.setReadOnly(false) // Then set the field editable for EVERYONE }else if (getActionName() == "产品审批通过"){ // If current action is 产品审批通过 Screen if(status == "产品审批+确认上线时间"){ // AND the issue status is "产品审批+确认上线时间" dateTimePicker.setReadOnly(false) // Then set the field editable for EVERYONE } }else if (getActionName() == null){ // If current action is Edit Screen if(status == "产品审批+确认上线时间"){ // AND the issue status is "产品审批+确认上线时间" if(currentUser == user1 || currentUser == user2){ // AND the current user is value of the User Picker fields dateTimePicker.setReadOnly(false) // Then set the field editable } } }