What I'm looking to do is execute a post function if a condition is met. The real world example here is that I want to copy a value from a Single Version Picker select list to the "Fix Version(s)" field IF the resolution is "Fixed".
Google's not helping me find a good answer for this and the idea of having a transition for "Fix" and a transition for "Other resolutions" seems convoluted and unnecessary.
Natalie and Timothy have mostly covered what I wanted to say on this one.
It boils down to what you really want is
1) to forget "conditions" - that's a word used in Jira for something specific, which is not what you need.
2) Put the logic for deciding what to write, and when, into a post-function. That's what they're for!
You can use Script Runner as you already commented and set the fix version within the scripted post function. First you have to find the version you need using the VersionManager before setting it.
VersionManager versionManager = ComponentAccessor.getVersionManager() def v = [versionManager.getVersion(issue.getProjectObject().id, '1.5')] issue.setFixVersions(v)
'1.5' is the name of the Version you want to set.
I think it would be a useful feature for post-functions to have "conditions", notwithstanding the terminology clash. That's why I added them to the built-in scripts. Although you can use proper conditions and lots of workflow actions, that's very hard to maintain.
> Beyond that, any help in how to use issue.setFixVersions() to pull the custom field value would be great appreciated
Not really sure what you're trying to do - might be better to ask a new question.
issue.setFixVersions() should work fine if your post-function is *first* in the list - but make sure you pass a Collection of Version objects.
I don't think what you want is a condition - a condition prevents a transition from being selectable if it's not met; but a validator wouldn't do it either - that only prevents a transition from being completed if it's not met. It sounds like what you want is just one post function; that checks to see if the resolution is "Fixed", and if so then set the Fix Version as you say.
Not sure why you don't want to do two transitions, because that seems the natural choice to me - you would have a "Fixed" transition (with a post function that sets the resolution to Fixed and the Fix version to what you want), and another one for the user to manually select the resolution they want.
I agree with Natalie. What you need is two transitions, one where your condition is met (resolution is not empty) and one where it's not (resolution is empty). Than add your postfunction to the transition with your condition - and you get what you want.
I get that using a different transition and conditions is the better answer (as opposed to writing my own post function). The only reason for not doing this is that we're in the process of migrating a great many issues from a legacy system that heavily relies on the workflow always being the same. Until that project is complete, I have to come up with another solution.
Using a simple conditional, I can test the resolution with Groovy Runner.
issue.resolution?.name == "Fixed"
Beyond that, any help in how to use issue.setFixVersions() to pull the custom field value would be great appreciated.
the new Workflow Enhancer might be for you: https://marketplace.atlassian.com/plugins/com.tng.jira.plugins.workflowenhancerIt's free and you can select any post function to be executed depending on a Boolean expression.
We'll greatly value any feedback if this is what you are looking for!
Both Conditioned Workflow Functions for JIRA and Create on Transition Plugin for JIRA provide options for conditioning logic within the post function to determine whether or not to run the requested action. Obviously, these are specific to the actions supported by the plugins (updating issues, creating issues).
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