Information Technology Reference
In-Depth Information
How to do it…
Perform the following steps to set up a validator with custom-scripted logic:
1. Select and edit the
Simple Workflow
.
2. Select the
Diagram
mode.
3. Click on the
Move to Backlog
global workflow transition.
4. Click on the
Validators
link from the panel on the right-hand side.
5. Click on
Add validator
, select
Script Validator
from the list, and click on
Add
.
Now enter the following script code in the
Condition
textbox:
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.ComponentManager
import org.apache.commons.lang.StringUtils
def customFieldManager =
ComponentManager.getInstance().getCustomFieldManager()
def solutionField =
customFieldManager.getCustomFieldObjectByName("Solution
Details")
def resolution = issue.getResolutionObject().getName()
def solution = issue.getCustomFieldValue(solutionField)
if(resolution == "Fixed" &&
StringUtils.isBlank(solution))
{
false
} else {
true
}
6. Enter the text "
You must provide the Solution Details if the
Resolution is set to Fixed.
" in the
Error
field.
7. Select
Solution Details
for
Field
.
8. Click on the
Add
button to complete the validator setup.
9. Click on
Publish Draft
to apply the change.