Using validators to make custom fields required on transition screens

JIRA Documentation

Index

It is currently not possible to make a field mandatory on any transition screen.The following Workflow Validator Extension is an example of how a user can use their custom field(s) to validate against in order to make these fields required on their associated transition screen.

Also note that although the below example uses validators on 'Custom Fields' it can also be configured for validation on 'System Fields' if configured correctly. Please vote on the following issue at JRA-5783 if you'd like the ability to make fields required on a per screen basis.

1. Create a class for your screen validator similar to the following:

**
 * An OSWorkflow validator that checks to see if the fields on the
 * Fix Screen have been filled in.
 */
public class FixScreenValidator  implements Validator
{

2. Insert custom field(s) names you wish to validate here:

protected void checkFields(Map args, Map transientVars, User user) throws InvalidInputException
    {
        issue = (MutableIssue) transientVars.get("issue");
        mods = issue.getModifiedFields();

        checkForVal("Resolution Description");
        checkForVal("Modules Affected");
        checkForVal("Test Considerations");

        if (invIn!=null) throw invIn;
    }

where the required fields would be inserted within the checkForVal function as such: checkForVal ("FIELD");

3. Configure the error message to suit the name of your screen validator class below:

String errmsg = "ERROR in FixScreenValidator(): Can't find the "+cfName+ " custom field. Please contact the system administrator.";

So replace FixScreenValidator with your class name for consistency.

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.