Hello All,
I've been able to figure out how to create a scheduled job thanks to scriptrunner's documentation, however I cannot figure out how to set a custom field with it. Here's what I have so far:
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("IT").id
summary = "Monthly Storage Analysis"
issueTypeId = "10208"
reporterId = user.name
description = "Storage & Backup team,\nPlease provide the storage utilization details for backups of SQL DBs per domain that we will be using for our monthly report. For Elasticsearch, information regarding H5R domain is sufficient."
}
def validationResult = issueService.validateCreate(user, issueInputParameters)
assert !validationResult.errorCollection.hasAnyErrors()
def issueResult = issueService.create(user, validationResult)
log.info "Issue created: ${issueResult.issue}"
I've found various pages on here that seem to answer this for other users but I haven't been able to get them to work.
For example, adding this leads to an error:
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def cf = customFieldManager.getCustomFieldObjectByName("Domain(s)")
issue.setCustomFieldValue(cf,"All Domains")
So in the end, I just want to set the custom field "Domain(s)" as "All Domains"