Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Behaviour groovy - Hide values of a select list for a group Edited

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

2 answers

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)

Hi,

actually this script is not good enough, as it also shows all disabled elements of my list ... :(

Help anyone ?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

72 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you