I need some help for the following configuration in JIRA:
On workflow transition screen, if the user selects "Implemented" on the Resolution dropdown on the screen, I would want a custom dropdown field a required one. Similarly, I also want the Fix Version field must have at least 1 Fix Version.
I don't think Behaviour plugin does what I need here because of the 'Resolution' condition here. Maybe I miss something?
If I am to script this, I can read the stored value, but in this case, the value chosen in the Resolution, custom dropdown field and the Fix Version are not saved to the database. How do I get the chosen value on the screen which is not yet saved to database?
Thanks.
Hi,
You can add a validator and check the value of Resolution. This will be the resolution on the screen. If resolution is "Implemented" you can then check for the FixVersion field.
You can do this using Script runner plugin if you are not using OnDemand JIRA.
import com.atlassian.jira.issue.Issue import com.opensymphony.workflow.InvalidInputException import org.apache.log4j.Category def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") Issue myIssue = issue if (myIssue.getResolutionObject().getName() == "Implemented" && ! myIssue.getFixVersions().size()) { invalidInputException = new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of \"Implemented\"") }
Here is the code from the plugin documentation.
Vijay
That works perfectly, Vijay. On a site question, how do I get a value on a custom dropdown? Please keep in mind that the value on this dropdown is not yet saved to the database yet, and thus I need the chosen value on the screen. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The validator has access to all the values selected/filled on the screen/transition which this validator is for. So you can get access to the customfield value as you get it for resolution. Below is pseudo code.
customFieldManager = ComponentAccessor.getCustomFieldManager() cf1= ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Custom Field Name") CustomFieldValue = issue.getCustomFieldValue(cf1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am trying to create a validator that only if a certain custom field by the name X equals (from a drop down list) "abc", then the user needs to attach an attachment by the name "xyz" in order to move to the finishing status of the ticket.
I tried to write a code for this- whiteout any success. can you help me please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I put this validator in my workflow:
import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
Issue myIssue = issue
if (myIssue.getResolution().getName() == "Fixed" && myIssue.getFixVersions().size()) {
invalidInputException = new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of \"Fixed\"")
}
It works with no errors, except that when the resolution is Fixed it does not thow the exception or give a message or anything, it just transitions the issue. Why? And how do I fix it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Never mind, I figured it out. Left out the "!" in the boolean expression.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gil,
Maybe you can try using some javascript customization directly to your field's description to fulfil those requirements.
Here are some links that might help with this.
Fields Allowing Custom HTML or JavaScript
Displaying a Field Based on Another Field Selection
Hope this helps
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.