Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
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

ScriptRunner Behaviours - removing option from a select list permanently changes configuration? Edited

Background:
We've painted ourselves into a little bit of a corner with the issue types we are using. We have Issue and External Issue which are used for internal vs customer issues for our company's main software product. Recently we added GUI Issue, and now we want to have External GUI Issues.

We've decided the best way to do this is just to re-use an existing "GUI Sub-component" custom field on the External Issue type, where when selected it will update some of the field templates to contain GUI stuff. The workflows between all of these issue types are identical, it's just there's a few fields difference between them.

So, the GUI Sub-component field is a select list which traditionally had has 5 options in it - when you create a GUI Issue, the component will be either X or Y, and then the Sub-component will further narrow down the choices with A, B, C, D or E.

Aim:
Now that we are using this field for External Issues, we want it to have the A-E options and also X and Y, but when a GUI Issue is created hide the X and Y options from the select list because they should never be selected in that case.

Problem:
So I've been using Script Runners - Behaviour module to achieve this.

I have a script that seems to work, except that when it runs it appears to be changing the actual configuration of the custom field select list.

When I go to create an External Issue all options A-E and X and Y show up in the list. If I change to a GUI Issue the list is timmed down to just A-E and X and Y are removed as expected. But then if I go back to create an external issue, it is only showing A-E and X and Y are nowhere to be found.

If I go into the custom field configuration and look at the options available on the select list, only A-E are now appearing, and X and Y have been deleted! This is very unexpected, initially I thought maybe another Jira admin removed them (which would be really unlikely as I'm the primary admin) but I've since shown that it seems to be the Behaviour script that is removing these items.

Only they're not fully removed - if I go to add option X back into this list, it gets added as element 6, but also the original X and Y re-appear in slots 7 and 8. So it seems like they're not 'properly' removed from Jira?

I've done a full re-index of the database and the behaviour is the same.

Here's my script, which is in the Initialiser for these issue types in the relevant project:

if (getActionName() == "Create")
{
if (getFieldById(ISSUE_TYPE).getFormValue() == 11202) //11202 is GUI Issue IssueType
{
/* X and Y are treated as top-level Components for GUI Issues.
* Therefore for GUI Issues, remove X and Y from the GUI Sub-component field */
def GUIfield = getFieldByName ("GUI Sub-component")
def GUIcfield = customFieldManager.getCustomFieldObjectByName("GUI Sub-component")
def fieldConfig = GUIcfield.getRelevantConfig(getIssueContext())
def options = ComponentAccessor.getComponent(OptionsManager).getOptions(fieldConfig)

options.removeAll {it.value in ['X', 'Y']}
GUIfield.setFieldOptions(options);
}
}

Any ideas why this would apparently be changing the actual custom field configuration? Any suggestions for how to do this instead?

We're on 5.6.13.1-p5 for ScriptRunner and Jira Software (Hosted) 8.5.1

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

253 views 3 20
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