custom validator script with custom error message ?

Hi,

I'm using a custom validator script to check if an attachment on a transition screen is given.
However, I don't know how to appropriately break up with some error message after detecting a missing attachment file.

it looks something like this:
DefaultTemporaryAttachmentsMonitorLocator loc = new DefaultTemporaryAttachmentsMonitorLocator()
TemporaryAttachmentsMonitor tam = loc.get(true)
Collection<TemporaryAttachment> tas = tam.getByIssueId(issue.getId())
if ( tas == null || tas.isEmpty() ) {
return "Error message"
}

instead of returning the error as string, I also tried to

InvalidInputException iie = new InvalidInputException("missing file attachment", "attach a file...")
throw iie

which breaks the whole script up with a null pointer exception instead of my desired error message
What do I need to do to make it work ?


Thanks in advance

2 answers

0 vote

You just need to set the variable invalidInputException to an instance of InvalidInputException . Note the case in those two strings.

...

invalidInputException = new InvalidInputException("attach a file...")

If you use the two-arg format the first arg should be a field ID.

Thanks !

I looked for it but didn't find the wiki page you showed me. It will be very useful in the future.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

851 views 2 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you