[Scriptrunner] finding the parent issue type

Gerhard Degel July 4, 2019

Hey all,

just wanted to ask a short question. I have a "Create Subtask" Action added to the transition. In the condition field I want to ask for the parent object issue type because I want the action to be executed exclusively for a specific issue type.

Thank you in advance and kind regards

Gerhard

3 answers

2 accepted

4 votes
Answer accepted
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2019

This will give you the value of parent issue type:

issue.getParentObject().getIssueTypeObject().getName()
0 votes
Answer accepted
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2019

Hi @Gerhard Degel ,

If you expand the examples you should have what you are asking for (and maybe some other useful ones for later) : 

image.pngAntoine

LaurieC July 1, 2021

@Antoine Berry just to confirm, the issuetype here is of the subtask correct? not the parent?

I'm trying to transition the parent only if the parent is a issuetype of 'Test'. I'm using the following, but it isn't working.

issue.parentObject.getIssueTypeObject().name == 'Test'

When I put logging in, it appears that I have it correct. 

2021-07-01 18:40:53,893 DEBUG [runner.ScriptBindingsManager]: issuetype of parent is Test 2021-07-01 18:40:53,894 DEBUG [runner.ScriptBindingsManager]: status of parent is Retest

But it isn't changing the parent status. I'm not sure how to debug that because it is a delivered post function.

I'm not a developer and would love your thoughts.

Thanks!
Laurie

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 2, 2021

Hi @LaurieC ,

the test condition

issue.parentObject.getIssueTypeObject().name == 'Test'

indeed tests against the parent issue type, so the condition will be true if the name of the parent subtask is "Test".

But what you are trying to achieve is a bit confusing so if you could add some insights that would help.

LaurieC July 2, 2021

Thanks so much for responding @Antoine Berry

I have an issuetype called "Test". I have a subtask called "Test Step" that allows me to build out the steps in a test scenario. When all of the Test Steps are passed, the parent Test issue type will be automatically passed using the "Transition parent when all subtasks are resolved" built in script. I don't need a condition on that one.

If, during the testing process, someone finds a problem and an action needs to be taken before all Test Steps can be completed, they can track that action using a generic subtask. If all of the generic subtasks are resolved and all of the Test Steps are resolved, I want the parent Test issue type to move to pass as well. But I don't want that same functionality for other parent issue types - therefore, I want a condition on the post function that will only run if the parent is a "Test" issue type. Does that make sense?

I tried putting the above condition in, but it doesn't seem to be working.

Any thoughts? Or am I think about this incorrectly?

Thanks again for your time!

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2021

Hi @LaurieC ,

First, I am very sorry for the late answer. I have tried your exact scenario and made it work. I suspect you have a recent version of Jira that makes one of the deprecated methods fail.

Could you please try instead : 

issue.parentObject.issueType.name == 'Test'

Make sure you add this postfunction on the resolve transition of the sub-task workflow, and that the correct parent transition is selected : 

image.png

 

Let me know how that went.

Antoine

1 vote
Andrew
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.
July 4, 2019

Suggest an answer

Log in or Sign up to answer