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

Joe Misner May 1, 2014

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

1 vote
Alexandru_Iacob
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2014

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