i added one behaviour script to pre-populate a custom field (single select list) with a default value. still its not working, not prepopulating on the screen.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.user.ApplicationUser;
import static com.atlassian.jira.issue.IssueFieldConstants.*
import org.apache.log4j.Level
import org.apache.log4j.Logger
Logger log = Logger.getLogger("ScriptLogger");
log.setLevel(Level.DEBUG)
log.debug "*********** I am being called for this action: " + getActionName()
if (getActionName() != "Create") {
return // not the initial action, so don't set default values
}
def zscm = getFieldByName("ZSCM Access")
def zscmoptionsManager = ComponentAccessor.getOptionsManager()
def zscmcustomFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = zscmcustomFieldManager.getCustomFieldObject("customfield_16251")
def zscmconfig = customField.getRelevantConfig(getIssueContext())
def zscmoptions = zscmoptionsManager.getOptions(zscmconfig)
log.debug "******* options found: " + zscmoptions
def zscmoptionToSelect = zscmoptions.find { it.value == "ReadOnly" }
log.debug "******* zscmoptionToSelect = " + zscmoptionToSelect.optionId
zscm.setFormValue(zscmoptionToSelect.optionId)
In the logs, reading the data correctly
at java.lang.Thread.run(Thread.java:748)
2019-09-12 05:09:59,067 http-nio-8080-exec-33 DEBUG 309x48375x1 kbd5jb /rest/scriptrunner/behaviours/latest/validatorsByPid.json [ScriptLogger] *********** I am being called for this action: Create
2019-09-12 05:09:59,068 http-nio-8080-exec-33 DEBUG 309x48375x1 kbd5jb /rest/scriptrunner/behaviours/latest/validatorsByPid.json [ScriptLogger] ******* options found: [ReadOnly, ReadWrite, NA]
2019-09-12 05:09:59,068 http-nio-8080-exec-33 DEBUG 309x48375x1 kbd5jb /rest/scriptrunner/behaviours/latest/validatorsByPid.json [ScriptLogger] ******* zscmoptionToSelect = 36814
but when creating the issue, ZSCM Access field is showing as "NONE". Please help.