Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Changing status when moving issue type

Valentina Benedetto
Contributor
August 7, 2020

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 :( 

 

2 answers

1 accepted

1 vote
Answer accepted
Subrat Mishra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 7, 2020

@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

Valentina Benedetto
Contributor
August 7, 2020

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. 

Screenshot 2020-08-07 at 10.29.16.pngScreenshot 2020-08-07 at 10.29.30.png

Like Howard Indochat likes this
Subrat Mishra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 7, 2020
  1. Can you confirm if you have "Issue Moved" event triggered properly when the issue-type change happened ?
  2. You don't need to check if the current and previous issues types are different . It will be different - that's what the first listener does. You can leave the condition blank and see if the second listener gets triggered .  
  3. You can use below condition instead :
def types = ['issuetype1','issuetype2']

issue.issueType.name in types 

 

Like # people like this
Valentina Benedetto
Contributor
August 7, 2020

Ah it helped, thanks a lot.

Like Subrat Mishra likes this
Subrat Mishra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 7, 2020

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 !

Alexandra Wiechers
Contributor
August 12, 2020

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!

Subrat Mishra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2020

Hi @Alexandra Wiechers  

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:

https://community.atlassian.com/t5/Jira-questions/Post-Function-to-move-an-issue-to-another-project/qaq-p/766320

Like Consulente Atlassian likes this
0 votes
Valentina Benedetto
Contributor
September 8, 2020

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 :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events