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

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

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

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

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)
}

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?

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
TAGS

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