Forums

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

Groovy expression to define subtask type

priym
Contributor
June 20, 2023

Hi Team,

I am trying to add warning message using post function. But this warning message should be visible if there is no subtask ticket for parent issue. If there is any subtask tickets it should not give warning message. Can you help me to write condition for that

2 answers

0 votes
Nic Brough -Adaptavist-
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.
June 30, 2023

Welcome to the Atlassian Community!

Post-functions can not give you warning messages, they are not connected to the UI at all.  The best you could do would be to create a comment on the issue that highlights that the user has done something wrong.

You might be able to do something with conditions, listeners, automation or validators though.

Could you tell us what the actual requirement is?  In the sense of where it should happen?  Is the warning for issue view?  Or you want to tell people about it during a transition?  Or something else?

0 votes
Frederik Vantroys
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.
June 20, 2023

Hi @priym ,

Something along the line of :

import com.atlassian.jira.component.ComponentAccessor

def subtaskManager = ComponentAccessor.getSubTaskManager()
def subtasks = subtaskManager.getSubTaskObjects(parentIssue)

if (subtasks.isEmpty()) {
// Add your warning message code here
// For example:
issue.setCustomFieldValue(warningField, "No subtask tickets found for this issue.")
}

Nic Brough -Adaptavist-
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.
June 20, 2023

This is code for Server, the question was about Cloud

Like Frederik Vantroys likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events