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!
This is the way to go!
Use script post function to achieve your goal. If you need help with this, you probably will get it right here on atlassian answers as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough [Adaptavist], pls, share example og postfunction:
If status moves to done and issue type bug is bug, then set resolution - fixed, version - earliest one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Henning beat me to it by 13s... the only thing maybe worth adding to this is to put this function as the first.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Be aware that this replaces all fix versions of the issue! If you want to add the version you have to combine the existing versions (issue.getFixVersions()) with the new one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is good. I'll need to make the version a variable to use the value in the custom field, but that's a perfect start.
THanks Henning!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Aaron,
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since you said you've already searched, then you're out of luck. You may need to write your own post function for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.