Here is the translation to English:
"I have implemented a Script Runner 'field(s) required validator' in my Jira workflow. This forces users to fill in the 'Fix Version/s' and 'Affected Version/s' fields as soon as the ticket moves to the 'Done' status. This part works well.
However, I want the assignee to be forced to fill out these fields only if the resolution is also set to 'Done'. Otherwise (for example, with the resolutions 'Won't Do' or 'Duplicate'), the validator should not be executed. There is a 'Condition' field in the validator for this purpose.
I entered the following script there,
import com.atlassian.jira.component.ComponentAccessor
def resolution = ComponentAccessor.getIssueManager().getIssueObject(issue.key).getResolutionObject()
def isResolutionDone = resolution?.name == "Done"
// Return true, wenn die Resolution "Done" ist, sonst false
return isResolutionDone
but unfortunately, it does not work. It does not prompt for the two fields even when the resolution is 'Done', and just closes."
Have you a solution or hint for me?
Thank you for your help
While what Tuncay suggested in the other answer will work, in the context of a condition script on a scriptrunner field required validator, you can just access the resolution directly from the built-in "issue" variable.
Your condition should work as a single line:
issue.resolution?.name == 'Done'
When the condition is true, the validator will evaluate the list of fields you flagged as required.
When the condition is false, the validator will be skipped.
If you retrieve an issue using IssueManager, it won't display the updated values that are going to be changed during the transition. This is because the transition has not been completed yet. Therefore, if you want to check the resolution field after it has been set/changed during the transition, you need to use the transientVars variable of the validate method in your Validator class.
Issue issue = (Issue) transientVars.get("issue");
I hope it 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.