Hello
I want to check a radio button value with a groovy script.
My radio button custom fiel ID is 15002, can have 3 choose : none, oui, non.
If value is on "yes", I want a true return
Here the script I wrote, but don't work
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_15002")
def value = issue.getCustomFieldValue(customField);
if (value == "oui")
{
return true
}
Any help ?
Hi @cendre Please try below code.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.issueManager
MutableIssue issue = event.issue as MutableIssue
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_15002")
def value = issue.getCustomFieldValue(customField)
if (value == "oui")
{
return true
}
I try with this code, and it's work
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
CustomField radioButton = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Configuration ?");
if(radioButton == null)
return false
if(radioButton.getValue(issue).toString().equals("oui"))
return true
else
return false
Thank @Subrat Mishra for your help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FWIW that solution doesn't seem to work with Behaviors. This is testing well today, both get and set. Some bonus code to get the Priority value.
import com.atlassian.jira.issue.IssueConstantImpl
def priorityField = getFieldById(fieldChanged)
def priorityFieldValue = priorityField.value
def selectedPriority = ((IssueConstantImpl) priorityField.value).name
def impactField = getFieldByName("Impact")
def selectedImpact = impactField.value
log.error("=====> Priority:" + selectedPriority + " Impact:" + selectedImpact)
if (selectedImpact == null) {
switch (selectedPriority) {
case "Low":
impactField.setFormValue("This issue is minor in nature.")
break
.
.
Context: We will set Priority based on a custom Impact radio button group. That code attached to Impact works fine for new issues. Today's task is to cut this into production and not bulk change thousands of old issues. Instead this code attached to Priority handles if Impact is null we need to set it according to Priority. Wish me luck.
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.