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.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ian Balas
If this answers your question, could you please accept the answer provided?
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ian Balas
I am trying to achieve the same thing as you and the following code using ScriptRunner works for me. Hope this can help others with the same needs!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Ian Balas ,
This looks interesting to me and I would like to implement it.
I am not familiar with Script Runner. Would this be created as a Behavior in Script Runner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Raphi LevineYes, this is implemented using ScriptRunner behavior. I simply pasted the code to the initializer section.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have Jira Cloud and not Server.
When I paste the above in, it shows Invalid Imports with this message.
"It looks like you're trying to import some Java classes intended to work with Jira Server. Unfortunately these won't work due to the differences between Jira Cloud and Jira Server.
ScriptRunner for Jira Cloud is designed to be used with the Jira Cloud REST APIs."
Any idea how I can accomplish this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I should have mentioned my organization used Jira Data Center but not Jira Cloud. I am afraid I don't know much about how the ScriptRunner works on the Jira Cloud side : (
I think you may want to look into the difference in ScriptRunner "Behavior" specifically: https://docs.adaptavist.com/sr4jc/latest/differences-between-scriptrunner-for-jira-server-and-jira-cloud/feature-parity#:~:text=alternatives%20are%20available.-,Behaviours,-Server/DC%20Feature
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.