I use ScriptRunner Script Listeners and Post Funtions to create sub-tasks.
However, with this particular workflow, I need a condition that checks to see if any other sub-tasks of the same type have already been created. If they have, then I need JIRA to restrict the action to ensure that only one sub-task per sub-task type can be created.
My project has 4 different sub-task types: Order Parts, Purge Parts, Claims, and Corrective Actions.
Can someone help me write a condition for a Script Listener and for a Post Function that checks the parent to see if a similar sub-task has already been created, and if it has restrict the action from completing.
In the end, my workflow should only allow one Order Parts sub-task, one Purge Parts sub-task, one Claims sub-task, and one Corrective Actions sub-task at any given time.
Sub-tasks are created at two different times: 1) Issue Create 2) Issue Update, when a field value changes either during a workflow transition (e.g. changing a value on a screen during workflow transition) or simply editing the field on the Issue View or Edit screen.
Regarding your second question, I am so glad that you asked. I didn't mean to say I was using Behaviours. I am actually using a Script Listener. The listener has a condition where it looks for the value of a field to equal "Yes" and then at those times it creates a sub-task. I have the Events for this listener set to Issue Create and Issue Update.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, I can't provide good advice to you without code examples, but here is example how you can find subtasks of issue and names
import com.atlassian.jira.component.ComponentAccessor
def subtaskToCreateName = "Task"
def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")
//getting subtasks names of given issue
def subtaskIssueTypes = issue.getSubTaskObjects().collect {it.getIssueType().getName()}
//checking if creating subtask alrealdy exist
if (!(subtaskToCreateName in subtaskIssueTypes)){
//your code to create subtask
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure what code you need to see. But for the Script Listener I have the Condition set to:
cfValues['Purge Stock']?.getValue() == 'Yes'
So when the custom field "Purge Stock" has a value of "Yes" this listener picks it up and create's a "Purge Stock" sub-task. This listener uses the Issue Create and Issue Update events. So essentially, I'm try to expand this condition so that not only will the Condition be to listen for when the custom field value is changed to "Yes" but also to ensure that there isn't already a "Purge Stock" sub-task created. Because there should only be one at a time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then try this condotion
def subtaskIssueTypes = issue.getSubTaskObjects().collect {it.getIssueType().getName()}
cfValues['Purge Stock']?.getValue() == 'Yes' && !('Purge Stock' in subtaskIssueTypes)
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.
My question is related this script can you please help me how to resolve below issue
Thanks
siva
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.