Cache problem when autopopulated to particular issuetype

Fayaz Abdul November 4, 2019

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
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 4, 2019

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.

Fayaz Abdul November 6, 2019

Hi @Peter-Dave Sheehan 

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

Thanks

Fayaz

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2019

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('')
}
}
}
Fayaz Abdul November 18, 2019

Hi @Peter-Dave Sheehan 

I have tried this too, but no luck.

And below is the code i have used before for particular project and issuetype is bug.

"

def desc = getFieldById("description")
def defaultValue = """
*Summary:*
*Steps to Reproduce:*
*Expected Results:*
*Actual Results:*
*URL:*
""".replaceAll(/ /, '')
// Only overwrite the description if it's not already set

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

"

Even after tried with your code, the issue is remains same.

Please let me know how to solve this.

Thanks,

Fayaz

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 18, 2019

Can you share screenshots of the behaviour mapping and the field configuration screens?

Suggest an answer

Log in or Sign up to answer