Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Set Portfolio 'Parent Link' field value using ScriptRunner

On a workflow transition I need to check that a parent issue has children with the Portfolio 'Parent Link' field which appears to work:

cfValues['Parent Link'] == null


However in creating the new child issue I am unable to set the 

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Parent Link'}
issue.setCustomFieldValue(cf, sourceIssue.key)


The following error is returned:

2018-05-29 07:47:17,418 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: EPIC-42, actionId: 81, file: null
groovy.lang.MissingPropertyException: No such property: Key for class: com.atlassian.jira.issue.IssueImpl
Possible solutions: key, id


4 answers

2 accepted

4 votes
Answer accepted

Dear all,

I have developed the following code and it seems to work in latest versions of 2020:

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

public static createParentLink(Issue parentIssue, Issue childIssue) {
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def parentLinkField = customFieldManager.getCustomFieldObjectByName("Parent Link")
def parentLinkFieldType = parentLinkField.getCustomFieldType()

JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser user = jiraAuthenticationContext.getUser();

def mutableParentIssue = parentLinkFieldType.getSingularObjectFromString(parentIssue.key)

def mutableIssue = issueManager.getIssueObject(

def changeHolder = new DefaultIssueChangeHolder()
parentLinkField.updateValue(null, mutableIssue, new ModifiedValue(parentLinkField, mutableParentIssue), changeHolder)
1 vote
Answer accepted

I contacted Adaptivist and they confirmed my fears:

There is not a currently known way to set the value of a Parent Link field programmatically using the Java API. It's possible that there are workarounds, but we don't know them as of yet. Retrieving the information from the field is possible (we actually have some JQL functions that do that), but there's not a good known way to set it. That is why setCustomFieldValue() works for every other custom field but the Parent Link field.

Atlassian advised:

Atlassian doesn't officially offer support for development questions or help with customisation

However I might be able to point you in the right direction:

It is possible to modify data via the database.

Here is an overview of tables that is used by JIRA Applications (Portfolio is listed):

You can also use the REST API from Portfolio


So I am going to follow the proposal from this community question: 

There's a way to do that:

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def parentLinkField = customFieldManager.getCustomFieldObject(10200L)
def parentLinkFieldType = parentLinkField.getCustomFieldType()

def newParentLink = some issue
if (newParentLink) {
newParentLink = parentLinkFieldType.getSingularObjectFromString((newParentLink as Issue).key)

def mutableIssue = issueManager.getIssueObject(
mutableIssue.setCustomFieldValue(parentLinkField, newParentLink)
issueManager.updateIssue(opsbot, mutableIssue, EventDispatchOption.ISSUE_UPDATED, false) 
Like # people like this

Hello @alexey_pelykh ,

I tried your code and works perfectly in most cases, but sometimes I get this error. Additionally this problem occurring only in Live environment. In test, on exactly the same task script works.

IssueService issueService = ComponentAccessor.getIssueService()
IssueManager issueManager = ComponentAccessor.getIssueManager()
ApplicationUser user = ComponentAccessor.getUserManager().getUserByName("svc.JIRA.Automation")
OptionsManager optionsManager = ComponentAccessor.getOptionsManager()
def issue = issueManager.getIssueByCurrentKey("BCM-1891")
def newIssue = issueManager.getIssueByCurrentKey("EDSGL-25")
def linkManager = ComponentAccessor.getIssueLinkManager()
def cfm = ComponentAccessor.getCustomFieldManager()
def projectField = cfm.getCustomFieldObject(14400)
def parentLinkField = cfm.getCustomFieldObject(14001)
def parentLinkFieldType = parentLinkField.getCustomFieldType()
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def query = jqlQueryParser.parseQuery("issuetype = Epic AND BCM ~ ${issue.key}")
def results =, user, PagerFilter.getUnlimitedFilter())
def parentLink
def bcmField = cfm.getCustomFieldObject(14210)
def bcmLookupField = cfm.getCustomFieldObject(13000)
def bcmFieldValue
def prjIssue
def bcmProject = (issue.getIssueType().getName() == "BCM Project")
def bcmEnhancement = (issue.getIssueType().getName() == "BCM Enhancement")
parentLink = parentLinkFieldType.getSingularObjectFromString("PRJ-81")
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)

issueManager.updateIssue(user, newIssue, EventDispatchOption.ISSUE_UPDATED, false)


2020-02-20 15:16:55,983 http-nio-8080-exec-3 ERROR Tomasz.Bryla 916x4448803x3 1ot76ru /rest/scriptrunner/latest/user/exec/ [c.a.r.j.customfields.parent.ParentCustomFieldHelper] 
 at sun.reflect.GeneratedMethodAccessor2852.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
 at java.lang.reflect.Method.invoke(
 at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(
 at com.sun.proxy.$Proxy35.setProperty(Unknown Source)
 ... 2 filtered
 at java.lang.reflect.Method.invoke(
 at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(
 at com.sun.proxy.$Proxy35.setProperty(Unknown Source)
 at com.atlassian.rm.common.env.issues.JiraIssuePropertyService.setProperty(
 at com.atlassian.rm.common.env.issues.JiraIssuePropertyService.set(
 at com.atlassian.rm.jpo.customfields.parent.issue.DefaultIssueParentService.setParentId(
 at com.atlassian.rm.jpo.customfields.parent.ParentCustomFieldHelper.setIssueParent(
 at com.atlassian.rm.jpo.customfields.parent.ParentCustomFieldType.createValue(
 at com.atlassian.rm.jpo.customfields.parent.ParentCustomFieldType.createValue(
 at com.atlassian.jira.issue.fields.ImmutableCustomField.createValue(
 at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(
 at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(
 at com.atlassian.jira.issue.managers.DefaultIssueManager.updateFieldValues(
 at com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(
 at com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(
 at com.atlassian.jira.issue.managers.RequestCachingIssueManager.updateIssue(
 at com.atlassian.jira.issue.IssueManager$updateIssue$ Source)
 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(
2 votes
Jonathan Muse _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 17, 2018

Hi, I am the product manager for an add-on called Power Scripts that lets you create the same type of automation as Script Runner. I know this question was already answered but I just wanted to share some information that might be helpful to others who are not groovy developers and are just looking for a solution to their problem. Instead of trying to copy and paste the code you don’t understand then crossing your fingers hoping it works, there is an easier solution.

#{Parent Link} = "TEST-1234";

That's all it would take in Power Scripts and its easy enough to understand. 

Where do I have to place this code. Listener ?

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 29, 2018 • edited

Try this

issue.setCustomFieldValue(cf, ComponentAccessor.issueManager.getIssueObject(parentIssue.key))
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 29, 2018 • edited

the above snippet expects that the script is executed on the child issue i.e."issue" object and parentIssue is the issue object of the "parent" (initiative/theme)

Tarun, I tried and received this error:

groovy.lang.MissingPropertyException: No such property: Key for class: com.atlassian.jira.issue.IssueImpl
Possible solutions: key, id

I have received that same error as well

Suggest an answer

Log in or Sign up to answer