Forums

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

when I pick issue from issue picker the summary of that issue should be displayed on custom field

Saudamini Deshmukh July 7, 2021

There are two custom fields on my screen.

1. associated parent issue(drop down).

2.Associated parent issue summary.

so now there are some issues in associated parent issue type drop down box. When I select any issue from drop down the summary of that selected issue should be displayed in the Associated parent issue summary field.

 

1 answer

0 votes
PD Sheehan
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.
July 7, 2021

Create a scriptrunner behaviour mapped to your project/issuetype.

Add your issue picker field to the configuration.

Then add a server-side script:

import com.atlassian.jira.component.ComponentAccessor
def issuePickerFld = getFieldById(fieldChanged)
def issueSummaryFld = getFieldByName("Parent Issue Summary") // <-- adjust for the correct field name
def parentIssueKey = issueSummaryFld.value
if(parentIssueKey){
def parentIssue = ComponentAccesso.rissueManager.getIssueObject(parentIssueKey)
issueSummaryField.setFormValue(parentIssue.summary).setReadOnly(true)
} else {
issueSummaryField.setFormValue("").setReadOnly(false)
}
Saudamini Deshmukh July 8, 2021

Hi thanks for your code

I have tried to run this code but its showing error on line

def parentIssue = ComponentAccessor.issueManager.getIssueObject(parentIssueKey)
issueSummaryFld.setFormValue(parentIssue.summary).setReadOnly(true)

on these two lines. Do I have to write a parent issue key id here?

PD Sheehan
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.
July 12, 2021

My apologies, I had a few errors in the code. But also, not all static type-checking errors are bad. Sometimes they can be ignored.

Try this:

import com.atlassian.jira.component.ComponentAccessor
def issuePickerFld = getFieldById(fieldChanged)
def issueSummaryFld = getFieldByName("Parent Issue Summary") // <-- adjust for the correct field name
def parentIssueKey = issuePickerFld.value as String
if(parentIssueKey){
def parentIssue = ComponentAccessor.issueManager.getIssueObject(parentIssueKey)
issueSummaryFld .setFormValue(parentIssue.summary).setReadOnly(true)
} else {
issueSummaryFld .setFormValue("").setReadOnly(false)
}

Suggest an answer

Log in or Sign up to answer