Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,622
Community Members
 
Community Events
168
Community Groups

Copy Issue Picker value(s) to Linked Issue Field

Edited

Hi All

Goal: To limit what issue types a user can link my "Feature" issue type too.

Looking for some help, Open to all suggestions. I have scriptrunner & JSU plugins.

I have a scripted field (Issue picker searcher type) called "Link your Issue" on the create screen. The issues available are limited to JQL search.

I now need to copy this value to the Linked Issue field. I have made the field read only and pre-set the link type using a behavior. I dont mind if the value is copied on the create screen using form values or after its created using a post function.

Or I could also have a workflow validator to limit the issue types users can link too

Any help much appreciated

Thanks

Richard 

2 answers

1 accepted

2 votes
Answer accepted

Using behavior is probably the simplest here.

Add the following  server side script on your "Link your issue" field:

def linkedIssuesFld = getFieldById("issuelinks-issues")
def linkInputFld = getFieldById(getFieldChanged())

def inputIssue = linkInputFld.value
if(inputIssue){
linkedIssueFld.setFormValue(inputIssue)
}

Thanks for your quick reply, that works perfectly. Simple and effective! 

@Peter-Dave Sheehan That is great, how to do it with duble issue picker, now if I Have 2 and i select second  issue picker, cleared first and write the second one.

I need 2 link

I think you can just grab the existing value first then add to it as an array.

def linkedIssuesFld = getFieldById("issuelinks-issues")
def linkInputFld = getFieldById(getFieldChanged())

def inputIssue = linkInputFld.value
if(inputIssue){
def linkedIssues = linkedIssueFld.formValue
if(linkedIssues instanceof String){
//if there is only one linked issue, it will be a simple String, we convert to ArrayList with the new value
linkedIssues = [linkedIssues,inputIssue]
} else {
//if there are more than one, it will already be an ArrayList, we just add to it
linkedIssues << inputIssue
}
linkedIssueFld.setFormValue(linkedIssues )
}
Like # people like this

Thanks for quick answer ,

Works if it fills in the right order :)

Thanks a lot

Where need to add these script

@Anuradha kumari  these are behaviour scripts on scriptrunner for jira

Hi, @Richard Duffy @Peter-Dave Sheehan 

Could you please help? I added the same script but seeing the below error.

image.png

There was a typo in the first response.

Make sure the declared variables in line 1 is spelled the same as the variable used in line 6

def linkedIssuesFld = getFieldById("issuelinks-issues")
def linkInputFld = getFieldById(getFieldChanged())

def inputIssue = linkInputFld.value
if(inputIssue){
linkedIssuesFld.setFormValue(inputIssue)
}

Hi @Peter-Dave Sheehan , Yes I got that, But the filed value is not copying for me.

for Example: 

  1.  my Epic 'DESP-2'
  2.  is my Feature 'DESART-3'

Now I want to Copy the value of  "STRATEGIC" field (Single Link picker) from Epic to Feature..

Needed: When STRATEGIC field is updated in EPIC the same value should be copied to STRATEGIC field in Feature and should be read-only

 

This is my setup in Behaviour Peter, Could you please help me here?

 

image.png

image.png

Hi, 

Is there also a way to debug this, in the behavior settings there is nothing like "if the script was run" - i impleted on my side - but nothing happens, or the issue dont get a new linked issue from the selected issue picket issue.

Thanks

Oli

Suggest an answer

Log in or Sign up to answer