Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Not able to run scripts related to behaviors Scriptrunner

Radosveta Delcheva May 20, 2020

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
AUG Leaders

Atlassian Community Events