Hi I want to allow creation of sub task only for the assigned user.
I use a validator condition in the create transition of the sub task.
For the validator I use script runner example script.
import com.atlassian.jira.component.ComponentAccessor parentIssue = ComponentAccessor.issueManager.getIssueObject(webwork.action.ActionContext.getRequest().getParameter("parentIssueId") as long) return currentUser == parentIssue.assignee
But for unknown reason It doesnt work.
Any hint, how to fix this?
Community moderators have prevented the ability to post new answers.
If you're using "simple scripted validator" the condition should be:
! issue.isSubTask() || issue.reporterId == issue.parentObject.assignee?.name
Shouldn't it be?: issue.isSubTask() && issue.reporterId == issue.parentObject.assignee?.name One additional question: I thought I cannot use the issue object, because the issue itself is not yet created. The validator is used in the create step of the issue. That's why I use the approach with "ComponentAccessor.issueManager".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> Shouldn't it be?: My way works when the workflow is the same for the parent as the subtask. Yours will fail if it's not a subtask. If you have a separate workflow for the subtask you don't need the first bit at all. > I thought I cannot use the issue object, because the issue itself is not yet created. The validator is used in the create step of the issue. That's why I use the approach with "ComponentAccessor.issueManager" I would have said the same, but I tested this on jira 6.4.x on the Create step and it worked as expected, which I was a bit surprised about.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also your approach of using ActionContext will fail in a bad way if the issue is created via REST, as in that case it will be null, so if you use that you need to guard against it being null.
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.