Hi,
Upon certain transitions, I am cloning an issue from one project to another using the Groovy Runner 'Clones and issue and links' function. However when the issue arrives in the new project it is still associated with the sprint from the originating project (GHS-5098)
My question is, can I use the 'Additional Actions' section of the 'Clones and issue and links' function to set the 'Sprint' field to null. When I do this manually it removes the issue from the originating sprint and places it in the backlog of the new project where it belongs.
I hope this is possible as this is a really annoying bug.
If you need to unset it just try setting it to null:
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'} issue.setCustomFieldValue(cf, null)
If you need to set it to a specific sprint you may need: sprintManager.getSprint(id) or something...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems if you null out Sprint, you cannot also set another custom field in the same additional action box or clone and link fails.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it should not fail... can you provide the code and exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'} issue.setCustomFieldValue(cf, null); def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Story Points'} issue.setCustomFieldValue(cf, null);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can't redeclare cf... def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'} issue.setCustomFieldValue(cf, null); cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Story Points'} issue.setCustomFieldValue(cf, null);
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.
Done, thanks Donncha. I copied your code to the answer for completeness...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Once again, your answer works. Thank you very much, your work on groovy runner and your answers to questions on this forum are much appreciated (as evidenced by your karma count)
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'}
issue.setCustomFieldValue(cf, null)
sets the value in the Sprint field to null, thereby forcing the cloned issue into the backlog of its new project as opposed to moving to the new project and remaining in the originating project's sprint.
If you could convert your comment to an answer I will mark it as 'answered'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's interesting... any log messages? You're trying to set it to a string, possibly that's not what it wants...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just looking into this a bit more, I think the Sprint field may be restricted somehow. For any other customfields I can just use the 'Set custom field' function in the Additional actions section of the 'Clones and issue and links' function i.e.
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'SomeField'}
issue.setCustomFieldValue(cf, 'Some text')
and this works fine.
However when I use
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'}
issue.setCustomFieldValue(cf, 'Sprint name')
not only does it not change the sprint field, it doesn't complete the clone and link function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All I can say is yes it is possible... personally I don;t have time to write the code. The sprint is some custom field, it should just be a case of finding the ID for that and nulling it out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I should note that my srcipting skills are fairly limited so I am asking both 'Is it possible' and 'How would I do it'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.