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
Is this for Jira Cloud or DC? Please clarify.
Thank you and Kind regards,
Ram
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:-
Below are a couple of test screenshots for your reference:-
1. Below is a sample Epic that is used for testing
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
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:-
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Has your question been answered?
If yes, please accept the answer.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1) Behavior
2) Parent issue in Parent Project:
3) Child issue in Child Project:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.