Change the behavior of the "Clones an issue and links" script.

André Mendonça July 20, 2014

Is there a way to set dynamically the "Target Project field" when cloning and linking an Issue?

I mean, put a customField with all projects, and the analyst choose it from a list and the cloned issue will be set on that Target project.

Thanks for your answers in advance.

3 answers

1 accepted

1 vote
Answer accepted
JamieA
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 22, 2014

You should be able to set it in the "Additional code"...

issue.setProjectObject ( project )

André Mendonça July 22, 2014

Thanks for the reply, unfortunately my "project List" custom field it won't work as expected.
It return a weird kind of value =\

By the way, i'm used this:

def cfObj = customFieldManager.getCustomFieldObject('customfield_11501')

def cfValue = issue.getCustomFieldValue(cfObj)

issue.setProjectObject (cfValue)

and, my custom field return This:

assert cfValue==cfObj
       |      | |
       |      | Project List
       |      false 

[id:10800, originalkey:CRW, description:, counter:76, name:Change Request, lead:039020, avatar:10011, assigneetype:3, key:CRW, url:]

JamieA
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 28, 2014

What type of field is "Project List"? Is it a list of project keys or project names or what?

Either way, you need to get the project object, using Project Manager.

André Mendonça July 29, 2014

Hi Jamie.,
My Field its a "Project Picker (single project) "

I Think that it's a default Jira (6.1.5) Field.

Actually, i'll leave this 'solution' and i'll make a Workaround to this.

Thanks anyway.

JamieA
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 29, 2014

Looks like that type returns a GenericValue and not a Project, in which case

issue.setProject (cfValue)

should work.

siddhesh March 21, 2018

HI @JamieA,

 I am trying same in my post function "Additional Issue Action" tab

But it is throwing an error

Capture.PNGtest.png

How can I resolve this issue?

Thanks in advance

Sid

1 vote
André Mendonça July 29, 2014

When i was trying a workaround i made it work.

Here are the code:

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue; 
 
 
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
CustomField customFieldProj = customFieldManager.getCustomFieldObjectByName("Project List");

def projVal = issue.getCustomFieldValue(customFieldProj)
//.toString()

issue.setProject (projVal)

Thanks a lot Jamie i was unable to resolve this without your simple help.

0 votes
André Mendonça July 27, 2014

Anyone have an Idea to resolve this?

Suggest an answer

Log in or Sign up to answer