Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Behavior to set description label based on a custom field

Philippe Puy October 3, 2018

Hi,

I'm trying to modify the example script where the behavior allows to change the description based on the value in priority field.

Though I need to do that with a custom field, and so far I don't get how to do it (I'm not used to that language at all).

I tried this:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.priority.Priority
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def SousCategorieCf = customFieldManager.getCustomFieldObjectByName("Sous catégorie")

if (getFieldById(getFieldChanged()).value as SousCategorieCf == "Abyla") {
    getFieldById("description")
        .setDescription("Merci de préciser l'élément impacté et la nature de l'impact")
}
else {
    getFieldById("description")
        .setDescription("Merci de préciser la nature de l'impact")

}

 

1 answer

0 votes
IT User Support October 3, 2018

Hi @Philippe Puy , what was the error? this seems to be working

Philippe Puy October 4, 2018

Hi @IT User Support

On the line

if (getFieldById(getFieldChanged()).value as SousCategorieCf == "Abyla") {

I get the error : Unable to resolve class SousCategorieCf 

So if I change the line into :

if (SousCategorieCf == "Abyla") {

I don't get this error anymore but I don't catch the changes either.

IT User Support October 4, 2018

@Philippe Puy , where did you put your code? initialiser or field behavior

Philippe Puy October 5, 2018

@IT User Supportfield behavior, server side script

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events