hi all,
I received the following code snippet from a user in this forum, this works great but it fires even when the select list is not changed. is it possible to fire this only when the select list value changed and during the edit action of the issue ? Please let me know.
// Get a pointer to both my fields def demoSelect = getFieldByName("Demo Select List") def demoMultiTxt = getFieldByName("Demo Multi Line Text Field") // Get the Value of the Select List Field def selectedVal = demoSelect.getValue() if (selectedVal != null){ demoMultiTxt.setRequired(true) }
Hi @saravanan subramanian
You can get the original value of the issue's custom field using underlyingIssue. For example in your case should be :
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = underlyingIssue
def tgtField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Demo Select List"}
// Get a pointer to both my fields
def demoSelect = getFieldByName("Demo Select List")
def demoMultiTxt = getFieldByName("Demo Multi Line Text Field")
// Get the Value of the Select List Field
def selectedVal = demoSelect?.getValue()
def previousVal = tgtField?.getValue(issue)
if (selectedVal?.toString()?.equalsIgnoreCase(previousVal?.toString())) {
log.debug("Values are the same I will set the require to false")
demoMultiTxt?.setRequired(false)
} else {
log.debug("Values are different I will set the require to true")
demoMultiTxt?.setRequired(true)
}
Thanks for your help . worked out great :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Thanos Batagiannis [Adaptavist] Yes - it is . Please help me out
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @saravanan subramanian Is this a behaviour script ?
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.