It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script Runner Escalation service Edited

So I am trying to automate the creation of a new tickets based on the end date of a resolved ticket using the Escalation service in script runner.

The JQL is project = vc AND issuetype = Story AND "Due Date" = -199d

The new issue is being created and linked to the resolved issue so all good there, however I want to populate a set of custom fields in the new ticket, in the script I'm testing with a field called 'Accessibility' or object "customfield_11008" which is a radio button selection options 'yes' or 'no'. I would like to set this to yes. However cannot get this to work.

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager

//origin issue - result of JQL
def issueManager = ComponentAccessor.getIssueManager()
def issueKey = issue.getKey();
def issueID = issue.getId();
def issueTypeName = issue.getIssueType().name
def issueStatusName = issue.getStatus().getSimpleStatus().getName()
log.debug "JC Key = $issueKey"
log.debug "JC TYPE = $issueTypeName"
log.debug "JC STATUS = $issueStatusName"
log.debug "JC ID = $issueID"
log.debug "JC Reporter = $"

def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def IssueLinkManager = ComponentAccessor.getIssueLinkManager()

//target project&issue
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("EGA").id
summary = issue.summary
issueTypeId = "10001"
reporterId =


def validationResult = issueService.validateCreate(user, issueInputParameters)
assert !validationResult.errorCollection.hasAnyErrors()

//new issue created
def issueResult = issueService.create(user, validationResult)
def newIssueID = issueResult.getIssue().getId()
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject("customfield_11008")
def fieldConfig = cf.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).getOptionForValue("Yes", null)
issue.setCustomFieldValue(cf, option)

log.debug "JC NEWID = $newIssueID" "Issue created: ${issueResult.issue}"

//link to origin issue
IssueLinkManager.createIssueLink(newIssueID, issueID, (Long)10003, (Long)0L, currentUser)

3 answers

Could you please try adding below line after setCustomFieldValue?

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Tired that and didnt work, infact it stopped the issue link from working

Can you see any error message? Actually it should work, there should be something missing.

Setting issue's custom field value might not work unless you cast it to MutableIssue or without issueManager.updateIssue service.

Not sure what you mean by MutableIssue or wothput issueManager service?

0 votes
Ben Poulson Community Leader Oct 11, 2019

In addition to the line @Tuncay_Senturk__Snapbytes_ suggested, could you add this line before the field value is set?


issue = issueResult.issue

As far as I can tell, the issue variable is never given a value, so it's just using the value scriptrunner set for it, which would be the original issue, not the new issue. Let me know if this worked!

Tried this and didnt work.

How about this one?

// add these to the import statements
import com.atlassian.jira.issue.ModifiedValue

def oldValue = issue.getCustomFieldValue(cf)
def newValue = optionsManager.getOptions(fieldConfig).getOptionForValue("Yes", null)
def changeHolder = new DefaultIssueChangeHolder() cf.updateValue(null, issue, new ModifiedValue(oldValue, newValue),changeHolder)

and please add  log.error("debug point n") statements so that we can better analyze how the code ran and what are the results. And please attach the logs.

sorry do not understand debug point n ? 

Since modifiying now get :-
runner.canned.jira.admin.EscalationService/preview [c.o.s.c.jira.admin.EscalationService] Escalation Service (Licence ) failed for issue VC-2871
groovy.lang.MissingPropertyException: No such property: fieldConfig for class: Script75

any further suggestions

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Keep your team in the loop with Team @mentions in Jira Software!

Hi everyone! My name is Jenny, a Product Manager at Atlassian. After launching Team @mentions in Confluence, we heard a lot of positive feedback from customers that they love how easy it is to @men...

221 views 4 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you