Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Parent Field Values to Child When Selecting Parent in Parent Link in Jira dc

Digvijay Singh Gehlot
Contributor
April 23, 2025

Hi Community, 

I want to copy the field values of Parent on Child Create screen when user selects a Parent in Parent Link field present on Child. 

For example, there is a PARNT-1000

user clicks on Create button and opens the Child Create screen. 

When selecting PARNT-1000 in Parent Link field, the Child fields automatically populate the same values as present in PARNT-1000 

Please guide if it can be possible via Jira automation and share which trigger/conditions/actions would be required to create such rule. 

Or if it is possible by scriptrunner behavior, please share any sample code to achieve the requirements. 

Please note: I am using Advanced Roadmap hierarchy and Parent is Initiative and Child is Portfolio Epic. 

Thanks

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
April 30, 2025

Hi @Digvijay Singh Gehlot

Is this for Jira Cloud or DC? Please clarify.

Thank you and Kind regards,
Ram

Digvijay Singh Gehlot
Contributor
May 1, 2025

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

Thank you for your message. 

I am looking for a solution in Jira data center. 

Please let me know if you need any other details, I'll promptly share with you according. 

Thanks

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 7, 2025

Hi @Digvijay Singh Gehlot

For your requirement, you will need to do something like this:-

import com.adaptavist.hapi.jira.issues.Issues
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def epicLink = getFieldById(fieldChanged)
def epicLinkValue = epicLink.value

def sampleList = getFieldByName('Sample List')
def orgList = getFieldByName('Organizations List')

sampleList.setFormValue('')
orgList.setFormValue('')

if (epicLinkValue) {
def epicIssue = Issues.getByKey(epicLinkValue.toString().substring(4))
def sampleListValue = epicIssue.getCustomFieldValue('Sample List')
def orgListValue = epicIssue.getCustomFieldValue('Organizations List')
sampleList.setFormValue(sampleListValue.toString())
orgList.setFormValue(orgListValue.toString())
}

Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications.

Below is a screenshot of the Behaviour configuration:-

behaviour_config.jpg

Below are a couple of test screenshots for your reference:-

1. Below is a sample Epic that is used for testing

sample_epic.jpg

In the sample Epic above, 2 custom fields, i.e. Sample List and Organization List, have values selected.

2. Below is a new Issue being created that will be linked to the Epic

create1.jpg

3. Once the Epic Link is selected in the Story, the Sample List and Organizations List field will automatically be updated, i.e. based on the value that has been set in the Epic issue as shown in the screenshot below:-

get_epic_values.jpg

If the Epic Link field is reset, the Sample List and Organizations List will also be reset automatically.

I hope this helps to answer your question. :)

Thank you and Kind regards,
Ram

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 14, 2025

Hi @Digvijay Singh Gehlot

Has your question been answered?

If yes, please accept the answer.

 

Thank you and Kind regards,
Ram

Digvijay Singh Gehlot
Contributor
May 20, 2025

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

Thank you for your message.

I tried to execute your suggested code and made some modification per my custom field types as below:

import com.adaptavist.hapi.jira.issues.Issues
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def parentLink = getFieldById(fieldChanged)
def parentLinkValue = parentLink.value

def radioType = getFieldByName('ZZZ Radio Type')
def
singleList = getFieldByName('ZZZ Single List')
def textType = getFieldByName('ZZZ Text Type')

radioType.setFormValue('')
singleList.setFormValue('')
textType.setFormValue('')

if (parentLinkValue) {
def parentIssue = Issues.getByKey(parentLinkValue.toString().substring(4))
def radioTypeValue = parentIssue.getCustomFieldValue('ZZZ Radio Type')
def singleListValue = parentIssue.getCustomFieldValue('ZZZ Single List')
def textTypeValue = parentIssue.getCustomFieldValue('ZZZ Text Type')
radioType.setFormValue(radioTypeValue.toString())
singleList.setFormValue(singleListValue.toString())
textType.setFormValue(textTypeValue.toString())
}

Per my configurations:

- I am using Parent Link field where I want to select the Parent (Initiative) Key on Child (Portfolio Epic) issue.

- I am using two projects: Parent issue in Parent Project P & Child issue is in Child Project C

- I am created a behavior where I mapped Child Project with Portfolio Epic and added Child Workflow in Guided Workflow

- I have added the above code under Parent Link field > server-side script

- I am using three types of custom fields: Radio Type, Select List (single choice), Multi-Text Field which is shared between Parent and Child projects both. 

Problem:

When selecting the Parent (ZPP-11 from Parent Project) in Parent Link (present in Child Project), the values of Radio, Select List, Text types are NOT reflecting automatically. There is no change in those custom fields on Child Create Screen.

Logs:

I am getting Log error as:

Option with value '' is not valid for field: customfield_RRRRR - Radio Type

Option with value '' is not valid for field: customfield_SSSSS - Select List (Single Choice)

Could you help me further with my observations?

Thank you

Digvijay Singh Gehlot
Contributor
May 20, 2025

1) Behavior 

IMG_20250520_172636.jpgIMG_20250520_172852.jpg

2) Parent issue in Parent Project:

IMG_20250520_172523.jpg

3) Child issue in Child Project:

IMG_20250520_172610.jpg

0 votes
Digvijay Singh Gehlot
Contributor
April 28, 2025

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

As per the above description, can you help me on how we can copy the value of a custom field (present on Parent) to Child custom field, by field value change of "Parent Link" present on Child issue?

For example. custom field "Radio Field" is present on both Parent and Child.

In Child Create screen, when PARNT-1000 is selected in Parent Link, the Parent value of Radio Field should get copied to Child automatically. 

Please guide how we can achieve this using scriptrunner behavior, any sample code for reference, would be a great help for learning.

Thanks

Suggest an answer

Log in or Sign up to answer