Setting field defaults is erasing when user edits issue


I am using a behaviour to set a field default based on the selection from a select list field.

When the user creates the issue, the field defaults are set correctly and the issue is created with the defaults in there. However, when the user edits the issue, if they added text to the defaults, anything that they entered is erased and set back to the original default. I know why this is the case, but don't know what condition to put in there to fix it. I have a condition "if (getActionName() != "Create Issue")", so that will pertain to editing an issue as well and will set the defaults again. My code is below, can you please help with a condition to use so that the fields don't get reset.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil

def dep = getFieldByName("Deployment Instructions")

def depVal = dep.getValue().toString()

def app = getFieldByName("Application")

def appVal = app.getValue().toString()

def ODIValue =

"""ODI Repository:
Delete existing scenarios? (yes/no):
Export Key (yes/no):
Subversion path:
Import Schedules? (yes/no):
List the scenarios to be imported below:""".replaceAll(/ /, '')

def WMValue =

"""Deployer Server:
Deployer Project:
Deployment Candidate:""".replaceAll(/ /, '')

def SOAValue =

"""Object Type (SOA, DVM, XSD):
Target Environment (e.g. test-na-1):
Deployment or Composite String:""".replaceAll(/ /, '')

if (getActionName() != "Create Issue"){

if (appVal == "ODI"){

if (appVal == "WebMethods"){

if (appVal == "SOA Suite"){

if (appVal != "ODI" & appVal != "SOA Suite" & appVal != "WebMethods"){

Thanks in advance!


1 answer

This widget could not be displayed.

You can really only use this on Create, where the text won't have a value.

I get in your case you can't do that because it should only use the default if the user selected a particular value from some other field.

So either create a different issue type for this, or you have check whether the field you are writing to is empty. If it might already have some other default you need to check the entire text is unchanged from any of the defaults.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

511 views 3 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you