Can I require a field be populated based on specific resolution values?

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2017

We have a text field we would like to be populated on resolve/close but only when the resolution is fixed, complete, or cannot reproduce.  Is this possible?

1 answer

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2017

you could create 2 transitions: 

  • fixed, complete, or cannot reproduce
  • other

And use 2 diferent transition screens and validators.

 

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2017

Thanks, but that's really not what we're looking for.  We need a validator that incorporates conditional logic.

Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2017

This is a script for simple script validator:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField

switch (issue?.getResolutionObject().getName()){
    case "fixed": case "complete": case "cannot reproduce":
        CustomField textField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("field name")
        return issue?.getCustomFieldValue(textField) != null;
            
    default:
        return true;           
}
Archer Vanwormerson August 8, 2022

For the transitions that go to the Resolved status (or whatever name you use for that status), you need to have a screen that includes the fields you want to validate and any other fields that you want to allow the agents to edit during the transition.

Using a Validator in the workflow will not put the "required field" asterisk next to those fields, but you can provide a message that will display if the validation fails. You can check each required field in a separate validator, or combine multiple fields in a single validator. The validators will be gone through in order, but only one validator's message will display. If there are multiple missing required fields, only the message for the first missing required field will display.

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 9, 2022

Thanks @Vasiliy Zverev but that organization didn't have ScriptRunner.

@Archer Vanwormerson I think if I were to try to solve this now (I've not been with that team in years) then, assuming I was using Jira Cloud (which has built in automation) I would create an automation rule to populate the field under those conditions.

Five years ago, when I wrote this, that wasn't an option.  Though, even if we could do so in Cloud, we were using Jira Server.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events