Would anyone be able to point me in the right direction regarding cloining an issue with all the custom fields found in such issue.
Currently I am doing the following to clone an issue (it works, but lacks alot of information).
Issue issue = event.issue
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_10126")
def cFieldValue = issue.getCustomFieldValue(cField) as String
def PROJECT_KEY_TO = "HTP"
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueFactory = ComponentAccessor.getIssueFactory()
def projectTo = ComponentAccessor.getProjectManager().getProjectByCurrentKey(PROJECT_KEY_TO)
def newIssue = issueFactory.cloneIssue(issue)
Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>;
UserMessageUtil.success("Issue "+newIssue.getKey()+" cloned to project"+ projectTo.getKey());
The Issue is succesfully cloned but for somereason none of my custom fields are cloned.
I would like to achieve a complete clone that copies over every custom field of the issue.
Any help is greatly appreciated!
What is your use case for this? Are you trying to have an issue cloned on a specific event? Is this script within a listener? Or do you want an issue cloned whenever it is transitioned?
ScriptRunner already has this functionality built-in depending on which verison you're using. You shouldn't really need to write this yourself.
You'll find this button on the both the listeners and script post-functions page:
You can use this built-in script to configure specifically which fields you want to clone:
This helps a lot, i am going to use this.
my Use Case is to clone an issue to another project whenever an issue is updated and it meets certain criterias
I am new to this type of Listener, could you help me figure out how to set my condition for it such that it runs once a certain custom field (which is a checkbox) has a value that contains the string "requires attention".
Thank you for your insight!
From that use case, that sounds like a perfect fit for this type of listener.
As for the condition, this will work:
'Your value here' in cfValues['Name of your checkbox here']*.value
It's worth noting that if you click the "Expand Examples" below the Conditions box, you will see a lot of really useful conditions. This is the same example condition used for multi-select lists.
Thanks for that!
i have one question regarding the condition. When you say name of checkbox is that the customfield name or the actual name that shows in the form? Custom field name is custom_10393 while the actual name shown in the form is Security Impact.
will that condition work even if the user clicks two or more values. For my usecase the user can click all 6 boxes but as long as "requires attention" is selected then it needs to be cloned. Will that condition work for my use case?
You should use the actual name of the custom field. So something like this maybe:
'requires attention' in cfValues['Security Impact']*.value
Yes, the condition will work regardless of how many checkboxes they select. cfValues will return an array of all the options selected. As long as they have the right one selected, the condition will return true because it will be a value within that array.
build-in clone function need select a target project, what is target project is based on a customfield value?
drop-down list A: with value 1, 2, 3,4,5,6
If 1 was selected, after click save issue create button, clone save issue to project B, and link these two issues.
If 2 was selected, after click save issue create button, clone save issue to project C, and link these two issues.
If 3 was selected, after click save issue create button, clone save issue to project B, and link these two issues.
If 4 was selected, after click save issue create button, clone save issue to project D, and link these two issues.
If 5 was selected, after click save issue create button, clone save issue to project B, and link these two issues.
If 6 was selected, after click save issue create button, clone save issue to project E, and link these two issues.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG