Hi,
I'm a total groovy beginner !
As the title says, I need to hide values of a select list for a group.
This select list has a lot of values like 60-80 and I need to hide all values starting with CC* (around 20-30 values), need to hide these to everyone except a specific group 'DAF'.
I know Behaviour allows to except so I think the script should only hide all values CC*, then I add the exception group DAF.
I just have a draft with elements I gathered everywhere, could you please help me ?
import com.atlassian.jira.component.ComponentAccessor
//def courrier = getFieldById("customfield_10500")
def CC = 'CC$'
def issue = ComponentAccessor.getIssueManager().getIssueObject("NS-15") // get issue where field exist
def courrier = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Type de Courrier")
def optionsManager = ComponentAccessor.getOptionsManager()
def options = optionsManager.getOptions(courrier.getRelevantConfig(issue))
options.each {
//if (it.value == "CC1 - courrier 1" || it.value == "CC2 - courrier 2" || it.value == "CC3 - courrier 3"){
//if (it.value =~ 'CC$'){
if (it.value == CC){
optionsManager.disableOption(it)
}
}
Thanks !
Sylvain
Hi,
actually this script is not good enough, as it also shows all disabled elements of my list ... :(
Help anyone ?
Once again I finally found help within my team, this one script should do the job and be useful to others (beginners) :
//Script to hide some values starting with CC*, in a select list
//With Behaviour, just use an exception/allowance to restric usage to users/groups
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.customfields.option.Option
def mailCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("My mail select list field")
def mail = getFieldByName("My mail select list field") // Get the select list field
def optionsManager = ComponentAccessor.getOptionsManager()
def options = optionsManager.getOptions(mailCF.getRelevantConfig(issueContext))
def CCoptions = options.findAll { item -> !item.toString().startsWith("CC")} // Using the "!" character allows to do the opposite/contrary
mail.setFieldOptions(CCoptions)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.