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.
Thanks,
Fayaz
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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('')
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @PD 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share screenshots of the behaviour mapping and the field configuration screens?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.