It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

is there a script that will validate that there are as many attachments as there are subtaks?

Scott Federman Dec 11, 2017

IS it possible to create a validator script that makes sure that an issue has at least the same number of attachments as it does sub-tasks? If so what would that script look like?

1 answer

0 votes
Thanos Batagiannis [Adaptavist] Community Leader Jan 04, 2018 • edited

Hi Scott,

For a Custom script validator the script would be 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.MutableIssue
import com.opensymphony.workflow.InvalidInputException

def issue = issue as MutableIssue

def subtasks = issue.subTaskObjects?.size()
def attachments = ComponentAccessor.getComponent(AttachmentManager).getAttachments(issue)?.size()

if (subtasks >= attachments) {
throw new InvalidInputException("Number of attachments should be greater than the number of subtasks")

Hope that helps.

Regards, Thanos

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Marketplace Apps & Integrations

Demo Den Ep. 4: Continuous Integration with CircleCI & Jira Software

Get ready! Demo Den Episode 4 is coming your way on Tuesday, May 28, 2018 with a Continuous Integration and Delivery special demo. CircleCI Director of Solutions Engineering, Eddie Webb will show us ...

434 views 0 4
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you