I do not have the custom field aspect working at all. I think I'm just missing some definition or import that is probably obvious (just not to me)? The intersect CF management you use looks great, but bombs for me not knowing what newissuecfs is. Also tried to simply get rid of the "$it" per your example, but I'm not sure how to define projectName (no such property). Groovy manuals, forums all around me, just not enough practice yet... :(
So - at current state is below: Added the import for customfield manager, changed the newissue to cloneissue rather than getissue, still have the old for loop for the cf options and I get the following in my logs...
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.For() is applicable for argument types: (java.util.ArrayList, Script124$_run_closure1_closure2) values: [[...all my custom fields...], Script124$_run_closure1_closure2@61774e]
Possible solutions: any(), wait(), every(), dump(), get(java.lang.String), put(java.lang.String, java.lang.Object)
A little more assistance would be greatly appreciated... TIA! Ran out of room on previous question: https://answers.atlassian.com/questions/29674/groovy-script-modification-clone-w-dependency-need-project-array
import com.atlassian.core.user.UserUtils
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.util.ImportUtils
import com.opensymphony.user.User
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category
import com.atlassian.jira.issue.CustomFieldManager //NEW
issueMgr = componentManager.getIssueManager()
issueFactory = componentManager.getIssueFactory()
projectMgr = ComponentManager.getInstance().getProjectManager()
versionManager = componentManager.getVersionManager()
customFieldManager = componentManager.getCustomFieldManager()
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
User currentUserObj = UserUtils.getUser(currentUser);
issue = issue
def wasIndexing = ImportUtils.indexIssues
ImportUtils.indexIssues = true
log = Category.getInstance("com.onresolve.jira.groovy.CreateDependentIssue")
// Configurable section
def ProjectList = ["Project A", "Project B"] //list of projects
ProjectList.each() {
// for other customisations change the code below
newissue = issueFactory.cloneIssue(issue)
newissue.setSummary ("Common - $issue.summary")
newissue.setProject (projectMgr.getProjectByName("${it}"))
def cf = customFieldManager.getCustomFieldObjects(issue) //???
For (cf) {
if (issue.getCustomFieldValue(cf)) {
newissue.setCustomFieldValue(cf, issue.getCustomFieldValue(cf))
}
}
issueMgr.createIssue(currentUserObj, newissue)
// get the current list of outwards depends on links to get the sequence number
linkMgr = ComponentManager.getInstance().getIssueLinkManager()
def sequence = 0
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if ("Depends" == link.issueLinkType.name) {
sequence++;
}
}
linkMgr = ComponentManager.getInstance().getIssueLinkManager()
linkMgr.createIssueLink (newissue.id, issue.id, 10001, sequence, currentUserObj)
ImportUtils.indexIssues = wasIndexing
}
Community moderators have prevented the ability to post new answers.
As Jon says it's for not For, but even if you change that it's still wrong. Given:
def cfList = customFieldManager.getCustomFieldObjects(issue)
cfList is a collection, so you can either of the following:
for (CustomField cf in cfList)
or
cfList.each {cf ->
You can remove the it by naming the parameter for the closure, like I did above. So in this case you would use cf instead of it.
Check out: http://groovy.codehaus.org/Looping
Perfect!!! Thanks so much - Drinks are on me if you're going to Summit this year. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cheers, mine's a "Doom Bar" ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie - One more thing on this. Can you help me add it so the cloned issue is assigned to the project lead?
I know this will mean I'll be booking a flight over the pond to get you a 2nd, but I'm due for a holiday soon anyway ;) Thanks in advance....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can post it to me ;-)
Replace this line:
newissue.setProject (projectMgr.getProjectByName("${it}"))
with:
def project = projectMgr.getProjectByName(it) newIssue.setProject(project) newIssue.setAssigneeId(project.get("lead"))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And... Currently only the first item is indexing? is there a magical trick to index everything?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need indexManager.reIndex(newIssue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks!!! Again! :) Ended up having to code it like this but it's working!
ImportUtils.setIndexIssues(true);
indexManager.reIndex(newIssue);
ImportUtils.setIndexIssues(false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While I was suggesting some debugging code over here I noticed a bug. The "For" used in your custom field loop should be lower-case.
Enjoy...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.