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

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

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){
descriptionField.setFormValue("")
}

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

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

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

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.

Hi JD,

did you resolve your problem?

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

Suggest an answer

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

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

233 views 2 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