Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Restrict sub-task options based on parent issue type

Is there a way with scriptrunner to restrict the sub-tasks that you can create depending on the parent issue that you're creating it in?

I want to limit the sub-task options when creating under a standard issue type called "Comms" to just "Plan", "Weekly Download", "Slack", "Email", "Weekly Wrap", "The Street", "Edit",  and "Write".

Referencing SRJIRA-1010, I thought this initialiser script would do the trick:

 

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor

Issue parentIssue = underlyingIssue.parentObject

def constantsManager = ComponentAccessor.getConstantsManager()
def commsIssueType = constantsManager.getAllIssueTypeObjects().find { it.name == "Comms" }

if(parentIssue.getIssueType().equals(commsIssueType)){
def subtaskSet = constantsManager.getAllIssueTypeObjects().findAll
{ it.name in ["Plan", "Weekly Download", "Slack", "Email", "Weekly Wrap", "The Street", "Edit", "Write"] }
.collectEntries{
[(it.id)]}

getFieldById("issuetype").setFieldOptions(subtaskSet)
}

 

But unfortunately I still see other sub-task issue types still available.

2 answers

Hi @Ian Balas

At the moment, this is not doable using the Behaviour.

The alternative would be to use javascript, as discussed in this community post

Another alternative suggested in this community post is to use ScriptRunner's validator.

I hope this helps to answer your question. :)

Thank you and Kind Regards,

Ram

Hi @Ian Balas

If this answers your question, could you please accept the answer provided?

Thank you and Kind Regards,
Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

The validator sort of helps. I'm able to restrict the user from creating unwanted subtasks for the parent issue type of concern (Comms). But it would be better if I could hide the unwanted subtasks as well to avoid confusion. 

The js solution I have yet to implement. This would be set as a validator as well?

Hi @Ian Balas

To add the Javascript, you try using ScriptRunner's Web Resource, or the alternative would be Jira's Announcement Banner.

I hope this helps to answer your question. :)

Thank you and Kind Regards,

Ram

Hi @Ian Balas 

You can refer to this documentation on how to retrieve the parentIssue properly.

I can confirm it does work. I hope this helps!

Max

Suggest an answer

Log in or Sign up to answer
TAGS

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