Hi,
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"){
dep.setFormValue(ODIValue)
}
if (appVal == "WebMethods"){
dep.setFormValue(WMValue)
}
if (appVal == "SOA Suite"){
dep.setFormValue(SOAValue)
}
if (appVal != "ODI" & appVal != "SOA Suite" & appVal != "WebMethods"){
dep.setFormValue("")
}
}
Thanks in advance!
Nick
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.
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.