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

Not able to run scripts related to behaviors Scriptrunner Edited

Dear all, 

As I am not so familiar with scripting I am trying to adjust some of the scripts related to behaviours to my needs for a prototype in Jira SD on Server. 

What I would like to achieve, but do not have success so far. I would be happy to get some help to show me the errors.

 

1 SOLVED - SEE BELOW. The priprity field used in the project has too many possibilities to offer, but for a particular issue types we need only 4 amongst them  - „High“, „Blocker“, „Medium“, „Low“. I have created a behaviour, but the scripts seems to be inconsistent as I get the error below

expecting ), found issue @ line 3, column 32 , this is by getAction Field.

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY
if (getActionName() == “Create issue” {
def constantsManager = ComponentAccessor.constantsManager
def allowedProrities = ConstantsManager.priorities.findAll {
it.name in [ „High“, „Blocker“, „Medium“, „Low“]
}
getField byId (PRIORITY).setFieldOptions (allowedPriorities)
}

Hi all, 

maybe to help somebody else. I was able to solve the 1. point, but still need help related to the hidden fields - to 2. point.

So the correct script is below:

2 things are very important - if there is default value - it will be visible despite the script.

2. where did I get those numbers -  it.id.toInteger()in [10,10001,8] because I  wanted to get visible Blocker, Medium, Low? - those are the ids of those values in priority - could be found in the priorities when you click on them with the mouse and there is a link and the number is in the end of the link.

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY

def constantsManager = ComponentAccessor.getConstantsManager()
def allowedPriorities = constantsManager.getPriorities().findAll() {
    it.id.toInteger()in [10,10001,8]
}.collectEntries {
    [(it.id): it.name]
}
getFieldById(PRIORITY).setFieldOptions(allowedPriorities)

 

2. I am not sure it is possible, but I just want to give it a try to hide several fields wehn an option from the select list of other field is selected. For example the custom field is called Organisation Management and by the option Delete Space the following fields should be hidden - Memory (which is a required field), Domain, Space, Oragnisation name. All are custom fields.

But still on the beginning I get the error - unexpected token management @ line 6 column 48

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
Def MemoryField= getFieldbyName (“Memory in GB”)
Def SelectList = getFieldbyName (“Organisation management”)
Def SelectListValue =SelectList.getValue ()
If (selectListValue == “Delete Space”) {
textField,setHidden (true)
} else {
textField.setHidden (hidden)
}

I have tried without that part as well - does not work.

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours

So my questions are: 1. what I am doing wrong to get the errors, how should that look like and

2. Is the second option possible as well - to hide more than 1 field by selection of the option and to hide required field as well, but the ticket needs to be created.

Many thanks in advance!

Kind regards 

Radosveta

 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Cannot save a repository using Chrome v83

Hello Bamboo Community, I'm Jey from Bamboo Support team. If you have upgraded your Chrome browser to version 83 recently, it is observed that the save operation just spins and never completes w...

71 views 1 1
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