Prevent subtask add in javascript


I have custom script to prevent user add new subtask when parent issue is in one status.

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {

    function stopFunction(){
         if( AJS.$('#status-val').text().indexOf('Waiting') > 0 

Code works great in standard issue view, but when use Issue Navigator Detail View it don't work. Only '+' button hide, but 'Create Sub-Task' button in More select list is still show.

What i'm doing wrong ? Thx for help

2 answers

This widget could not be displayed.

What you're doing wrong mostly boils down to "using javascript". You need totally different code for every place where someone could do this, and as there's several places, it's going to be a nightmare to code and even worse to maintain or upgrade. Plus, as it's javascript, it's a doddle to bypass.

I'd look at setting the "do not edit" flag on that status, that will block subtasks being added. Properly.

Ok, but i want to edit parent issue. I want to prevent add new subtask only.

Property jira.issues.subtask.create want work...

This widget could not be displayed.

You could use a validator on the subtask workflow... and/or a behaviour on the subtask type that shows a big red message saying "stop trying this, you won't be able to commit".

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Statuspage

What are your best incident management tips and stories? #HugOps

 👋Community members! Downtime happens. And great incident response takes a village. Teams like Support, Dev, SRE, Ops, IT, and Marketing have to come together to resolve the problem while keep...

35 views 2 3
Join discussion

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