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

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

Behaviours/Groovy how can i get description field content on create issue screen?


Based on code example, located here i made behaviour with description template, but it not working right.

I guess, this part is not working

if (! underlyingIssue?.description) {  desc.setFormValue(defaultValue) }

Because underlyingIssue not exists while creating new issue. Am i right?


So i tried to do something like this:

//issuetype 10004 = bug

//get some values
def descriptionField = getFieldById("description")
def issueTypeField = getFieldById("issuetype")
def issueTypeValue = issueTypeField.getValue()
def descriptionValue = descriptionField.getValue()
def descriptionValue1 = descriptionField.getFormValue()

//define template
def templateValue = """h5. Env:
h5. Version:

h5. Bug description

h5. Steps to reproduce:

h5. Expected result:

h5. Actual result: """.replaceAll(/ /, '') + " " + descriptionValue + " " + descriptionValue1 //i've added description values here, to see, if it contain something

// if description already contain template, and issueType changed from bug to another, clear form
if (descriptionValue == templateValue && issueTypeValue != 10004){

//If descriptionValue not exist(if it null then?) and issuetype = bug, set description to template
if (!descriptionValue && issueTypeValue == 10004){

if (descriptionValue != templateValue && issueTypeValue == 10004){

I hope code not ruined, on creating this question, parser noticed, that some content was replaced.

Main thing that i want, is: when description equal template and type not equal bug, description field cleared. If description not exists and type equal bug, description filling with template. Third case is when description is not null, but not equal template -> do nothing

I got stuck in one thing, if description contain some information, descriptionValue still "Null".

If i add some logging, i get:

[c.o.j.groovy.user.FieldBehaviours] descriptionValue null
[c.o.j.groovy.user.FieldBehaviours] descriptionValue1 null

I found in some examples two possible(i think) methods of getting value of form, but all of them return Null.  getValue works perfectly with all the fields, except description and summary. Maybe i'm doing something wrong.

So i have a question, how can i get current description on create issue screen, or i can only set it?

I need it not only to compare with template, but also to save content, for example if user started to create random issue, but later realise, that he's not setted issue type to bug, changing to bug, and all contents of description got cleared and filled with template, this is not a good thing.

2 answers

Hi JD,

did you resolve your problem?

I also can't get the value of the description field 

0 votes

I think the issue is that at the time that the initializer runs, the form field for the description has not yet been populated by jira (which seems to keep it in memory and re-apply it to the field after the fields are rendered).

Put your code against the Issue Type field instead of the initializer, it will refresh each time you change the issue type.

It also runs when the form is first initialised because it runs when the issueType field is populated from the default.

But this won't work when you are using the standalone CreateIssue.jspa which shows project/issue type then open a new screen with all the fields. For that case, you will still need the initializer. But you'll have to be careful that they work well together.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

483 views 16 17
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