Hi,
I need some help in disabling Cascading Select Parent Options by running the script monthly once.
Lets say I have two cascade select fields
Field 1 with parent options 'Dec'-19', 'Jan-19', 'Feb-19','Mar-19
Field 2 with parent options ' 'Dec'-19', 'Jan-19', 'Feb-19','Mar-19
Requirement is
I was exploring Script Runner, python jira REST for past couple of days, but could not find a way of doing. I have to do this monthly once so that I can make users do what I want them to do from that month onwards
Thank you in advance, any help/pointers is appreciated
with warm regards
ramki
As soon as I posted and searched again, Thanks to Mark Markov, I got the answer from https://community.atlassian.com/t5/Jira-questions/Disable-particular-options-with-groovy-script-runner/qaq-p/871249
I am also adding a small additional feature here which is to check whether the option is disabled or not ( I was searching for it and found again today :) )
//https://community.atlassian.com/t5/Jira-questions/Disable-particular-options-with-groovy-script-runner/qaq-p/871249
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.Options
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
// change xxxx with id of your cascaded custom field
def cascSelectCf = customFieldManager.getCustomFieldObjectByName("DUMMY_ONE")
// get an issue just for relevant config
def issue = issueManager.getIssueObject("PROJ-1")
Options options = optionsManager.getOptions(cascSelectCf.getRelevantConfig(issue));
def rootOptions = options.getRootOptions()
rootOptions.each {
if(it.getDisabled() == false) {
log.info "Option is disabled"
}
if(it.value == "Dec-18") {
//log.info "$it.optionId - $it.value"
optionsManager.disableOption( it)
//optionsManager.enableOption( it)
}
}
All the time I was searching to disable cascade select option, this time I just searched disable options and hit the jackpot
Interesting usecase. Thank you for posting the solution you found. You should nark your own solution as tge accepted one, so that people know that the problem is solved😊
With kind regards
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it's a cascading field, it will disable the root options, not the child options. You need to update your code to catch the child options and then perform disabled/enabled.
Thanks,
Srikanth Ganipisetty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!
Help us plant more trees
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.