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

Cache problem when autopopulated to particular issuetype

Hello Adaptavist,

Auto-populated some content in Description for a 'Bug' issue type in Particular Project, when we change the issue type from Bug to other, the description remains the same.

FYI: From other issue types to Bug, auto-populate is working as expected.

And also i have tried with

enableCache = {-> false}

Getting an error, please check attched screenshot.

Screenshot (69).png

Thanks,
Fayaz

1 answer

0 votes

In order to have the behavior script "kick in" when you change to other issue types or projects, you will need to use all issue types and all projects in the behavior mapping.

Then, in your script, check the issueContext.project.key and issueContext.issueType.name and then populate with your default when they match and populate with empty strings when they don't.

The one caveat you should be aware of is that any text typed by the user in the description will be erased if they happen to change their mind mid-creation on which issue type it should be.

You could avoid that by first comparing the current form value against the default, and reset only if they match.

The enableCache = {-> false} is only applicable for scripted field as far as I can tell from the documentation.

Hi @Peter-Dave Sheehan 

Could you please explore in detail, so that i can understand.

Thanks

Fayaz

Behavior script only executed when you change TO a project/issue type that is in the mapping.

When you change FROM a mapped issue type or project to one without mapping, then no script is executed.

So if you set your mapping to All Project and All Issue Types and start your script this way:

def myMapping = [projects: ['ABC', 'XYZ'], issueTypes:['Bug']]
def defaultDesc = """\
Put your default desc here.
""".stripIndent()
def descField = getFieldById('description')

//only try to set defaults during issue creation
if (!underlyingIssue) {
//check that the issue being created is in a context where we want the default
if(issueContext.projectObject.key in myMapping.projects && issueContext.issueType.name in myMapping.issueTypes){
descField.setFormValue(defaultDesc)
} else {
//clear the default, but only if user hasn't made any changes yet
if(descField.value == defaultDesc){
descField.setFormValue('')
}
}
}

Suggest an answer

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

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

275 views 1 2
Join discussion

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