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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Copy Affects Versions from an issue to another with scriptrunner

Hi,

I'm creating a behaviour in scriptrunner to copy specific fields of the current issue to a new task in another project.

I'm able to do it on all the fields I require except "Affects Versions" which is not copying anything.

Here is my script : 

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()

if (getBehaviourContextId() == "create-myproject-linked-task") {
getFieldById("project-field").setReadOnly(true)
getFieldById("issuetype-field").setReadOnly(true)

def contextIssue = issueManager.getIssueObject(getContextIssueId())

getFieldById("summary").setFormValue(" support request for ${contextIssue.key}").setReadOnly(true)
getFieldById("issuelinks-linktype").setFormValue("relates to").setReadOnly(true)
getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true)
getFieldById("labels").setFormValue("Customer,Support").setReadOnly(true)
getFieldById("versions").setFormValue(contextIssue.key).setReadOnly(false)
getFieldById("description").setFormValue("Only for time tracking for L4 support. Any functional or technical analysis and comments should be tracked in related project.")
}


 As you can see the faulty line is :

getFieldById("versions").setFormValue(contextIssue.key).setReadOnly(false)

I searched a solution on internet for hours but did not find anything. I guess it has something to do with the fact that it returns a list and not a string but I can't find the proper way to make it work.

Does anybody have the solution for this?

thanks

1 answer

Hi @sylvain_t 

In your code, you appear to be copying an Issue Key into a version field. Is that what you intended to do?

As the versions are pre-defined values for a project, I suspect that would not work unless you also created versions for all of the possible keys that could be loaded.

Best regards,

Bill

Hi @Bill Sheboy , thanks for the feedback.

What I want to achieve is to copy the value of the"Affects version" field into the same field for a sub-task in another project.

I could never achieve this and we are just living with it. I guess that it's indeed an issue with the "Affects version' field behavior itself, not permitting to copy a raw value but instead copying a unique ID that is not existing in the other project.

That is correct, as the versions are defined values values for each project.  That helps with change management (Fix Version) and defect impact analysis (Affects Version).

If you first create the version in the target (destination) project you can then set it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
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