Trying to write a SIL script for Create Sub-task screen that looks at Parent issueType

Hello!

I am trying to address a gap in the Jira architecture in that you cannot restrict sub-tasks given a parent issue type. See this very old request here - https://jira.atlassian.com/browse/JRA-7990

I am attemptoing to use JJUPIN Live Fields to accomplish this. We have used this to restrict issue types based on things like group membership or resolution (like here - http://confluence.kepler-rominfo.com/display/TR/Restricting+resolutions+based+on+issue+type). So my basic logic is as follows...identify the parent tasks that should not allow sub-tasks, identify the sub-task types to restrict and then if the parent task used should be restricted, do so via live fields function.

// array of parent issue types that should not allow subtasks

string[] standAloneParentTypes = {"Idea", "Bug", "User Access Request"};



// array of the sub-task issue types to restrict

string[] forbiddenTypes = {"UX Design Sub-task", "QA Sub-task", "Tech Design Sub-task"};



// If the parent issue type is one that cannot have sub-tasks, restrict options to not include them

if (arrayFind(standAloneParentTypes, issueType) != -1) {

    lfRestrictSelectOptions("issueType", forbiddenTypes);

}

This does not seem to work. I am pretty sure that I am not reading the issueType of the parent task from which a subtask is being created. Anyone know how I would go about doing this? I have an idea of adding a custom field like allowsSubtasks and set that post creation and then use it in this same scenario if I cannot get this to work.

1 answer

This widget could not be displayed.

Hi Joe,

Your syntax is worng. You should use parent.issueType instead of "<strong>issueType</strong>" in your if clause, like this:

if (arrayFind(standAloneParentTypes, parent.issueType) != -1) {
lfRestrictSelectOptions("issueType", forbiddenTypes);
}
This will work on inline edit, normal edit and transition screen.
However, on the create issue screen we don't have access to the parent variable, so you should try to restrict the sub-tasks issue types using a SIL validator on the Create Issue tranistion.
Here's an example of a SIL Validator based on the parent's status:
You SIL validator script would be:
if (arrayFind(standAloneParentTypes, parent.issueType) != -1 && arrayFind(forbiddenTypes, issueType) != -1) {
return false, "issueType", "You cannot select issue type '" + issueType + "'";
}
Hope this helps.

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 New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

55 views 1 0
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