I'm using Script Runner's Behaviours to have a default value for fixversion when creating a ticket. In this scenario, how could I prevent Behaviours from setting that field's value when the user chooses the option "create another" to create one more ticket?
The Create Another checkbox copies over fields all on its own to start with. Behaviours are javascript-based, meaning that they start after the form is loaded. As such, you should be able to tell your behaviour to only add the default value if the field is empty. You'll still get the copied value from the previous issue (which is what you want, I reckon).
Something like:
import com.atlassian.jira.issue.IssueFieldConstants
def fixVersion = getFieldById(IssueFieldConstants.FIX_FOR_VERSIONS)
def defaultFixVersion //set your default fix version here
if (!fixVersion.getValue()) {
fixVersion.setFormValue(defaultFixVersion)
}
Unfortunately that doesn't seem to work. When I check the value of fixVersion, it always returns null. Same thing for other fields that are pre-filled by the "create another" functionality.
I can successfully set the value of fixVersion, but it always overwrites the value that "create another" would have put in there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm, you're right. Having reproduced this, it doesn't even look like Behaviours is firing before the "Create another" functionality populates that field. The version is there from the previous issue, then it gets overwritten.
However, if I put the same script on the Fix Version/s field instead of in an initializer, it seems to work as you'd want.
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.