Hi! I need to build a behavior script for editing the epic link field based on the reporter. I'm using a server-side script function, but the script doesn't work when the reporter is a different user.
Follow my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
def reporterfield = getFieldByName("reporter")
def cfEpicLink = customFieldManager.getCustomFieldObjectsByName("Epic Link")
if(reporterfield != ("rocket")){
getFieldByName("Epic Link").setReadOnly(false);
}
else
reporterfield == ("rocket")
getFieldByName("Epic Link").setReadOnly(true)
try this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def cfEpicLink = customFieldManager.getCustomFieldObjectsByName("Epic Link")
def userManager = ComponentAccessor.getUserManager()
def reporterField = getFieldById("reporter")
def reporterValue = reporterField.getValue()
def reporterUser = userManager.getUserByName(reporterValue.toString())
if(reporterUser != ("rocket")){
getFieldByName("Epic Link").setReadOnly(false);
}
else
reporterUser == ("rocket")
getFieldByName("Epic Link").setReadOnly(true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.