I'm using Jira server ver 8.13.3
I have a text based custom field called "Deliverables" and I'm trying to create a Custom scheduled job to create an issuetype story every day with the "Deliverables" field set to "insert custom text".
Deliverables = customfield_13518
I've tried the following but it never actually injects the text into the custom field
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = Component.Accessor.customFieldManager()
def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("PROJ").id
summary = "reoccurring task"
issueTypeId = "21"
reporterId = user.name
description = "Daily Task Checklist"
customfield_13518 = "Submit Form 1362"
}
def validationResult = issueService.validateCreate(user, issueInputParameters)
assert !validationResult.errorCollection.hasAnyErrors()
def issueResult = issueService.create(user, validationResult)
log.info "Issue created: ${issueResult.issue}"
Hi @David Howe Try to insert value in custom field using below code :-
issueInputParameters.addCustomFieldValue(cf.idAsLong, requestTypeValue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Howe :- Working Code for me :-
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def requestTypeValue = "Submit Form 1362" //replace it with the one you want - see note below
def constantsManager = ComponentAccessor.getConstantsManager()
def issueType = constantsManager.getAllIssueTypeObjects().find {it.name.equalsIgnoreCase("New Project Request")}
def issueInputParameters = issueService.newIssueInputParameters()
def customFiledmanager = ComponentAccessor.getCustomFieldManager()
def cf = customFiledmanager.getCustomFieldObjectByName("CA Ticket#")
issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("CJS").id
summary = "Issue created from script"
issueTypeId = issueType.getId()
reporterId = "vikrant-yadav2"
assigneeId = "vikrant-yadav2"
}
issueInputParameters.addCustomFieldValue(cf.idAsLong, requestTypeValue)
def validationResult = issueService.validateCreate(user, issueInputParameters)
assert !validationResult.errorCollection.hasAnyErrors()
def issueResult = issueService.create(user, validationResult)
assert !issueResult.errorCollection.hasAnyErrors()
return "Issue created: ${issueResult.issue}"
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.