Hi Community,
I am working on the project now where we have 3 issue types and 2 workflows. Issuetype1 and Issuetype2 have workflow1 and issuetype3 has a workflow 2.
Workflow1 has an approval as a first step after creation, workflow2 doesn't have approval. I am trying to achieve the functionality so that whenever issuetype3 moved to issuetype1 or issuetype2, it is sent in workflow back to the approval step.
I am using scriptrunner for this.I tried to use listeners in the postfunction on the issue transition and put this code as a condition:
issue.issueType.name != originalIssue.issueType.name &&
originalIssue.issueType.name = "Issuetype1"
As an action I use transition "back to approval"
But it doesn't even run meaning condition isn't set correctly :(
@Valentina Benedetto I believe you are using Listener as "Issue Moved" event .
You can try this :
//SR Listener Type: Fires an event when condition is true
//Event: Issue Updated
//Event to Trigger: Issue Moved
//Condition
def types=['issuetype']
changeItems.any {
it.get('field') in types
}
The above listener will trigger an "Issue Moved" event when issue-type change happens for an issue . Then this "Issue Moved" event can be caught by another listener ( this is the listener you mentioned above for the workflow status change ) .
I had issues in past where it didn't automatically trigger "Issue Moved" event when issue-type/project changed . This solution works for me where I manually trigger an issue moved event and then catch it in another listener .
Hope it helps !
Thanks,
Subrat
Hi Subrat,
Thanks for your quick reply!
I used Fast-track transition an issue in the postfunction before.
Now I tried as you described above just create 2 listeners: as in the screenshots and not addining anything to the postfunctions. still doesn't work for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def types = ['issuetype1','issuetype2']
issue.issueType.name in types
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.
I think, for your requirement you can have everything in a single listener . You don't need the first listener , just use the condition in the second one along with other conditions (Event : Issue Updated) .
That should be good enough !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Subrat,
I'm a beginner with ScriptRunner but I'm trying to somewhat accomplish the same thing - I need to automate the "Move" of an issue from one Issue Type to another. The problem being that they have different workflows (hence why I need to Move it and not just update the issue type).
I created a Post Function on a specific transition that would change the issue type but then the workflow is broken. If I use the listener you mentioned to trigger an Issue Move, will that help take care of the workflow issue?
Essentially, I'm trying to automate the "move" execution rather than having to do that manually. Is that possible with Script Runner Listeners and/or Post Functions? Appreciate any help/insight. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your requirement is different . You are trying to move the issue through automation .
Several things might be different between two different issue-types like workflow (transition ID), fields..etc .
If you have already done a move through UI , you might have noticed Jira asking you to fill the differences between two issue-types . Unless you have both issue-types having similar fields/workflows , it's not an easy thing to do .
I found a similar response in the below link:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now I am trying to change the subtasks issue types while moving the parents issue type.
Lets say we have a "Task" issue with a subtask "Task-subtask" and then we move the parent. issue to "Bug" and I want subtask to automatically change to "Bug-subtask"
I am trying to add the following code in the additional issue action under the Fast-track transition an issue Listener:
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def subTasks = issue.getSubTaskObjects()
subTasks.each {
def newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(issue.projectObject).find{it.name=="Bug- Sub-Task"}
if (newIssueType) issue.setIssueTypeObject(newIssueType)}
with the condition like this:
def types = ['Bug']
issue.issueType.name in types
But it fails :(
I tried to add this code as postfunction on the parentissue transition but then it changes the issue type of parent issue to Bug-subtask
Trying to figure our what might be the case here. Will be happy to hear any advices, thanks in advance :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.