I am trying to use a simple scripted validator that will block a transition if a radio button has not been left as the default option "none".
The field with my radio button is field ID 10700. The default option of the field is "None" and I would like my script to pass validation, only when any radio button other than "None" has been selected.
The current behaviour is that it is correctly blocking the transition when the radio button is "None" however it is also blocking the transition when any other radio button is selected, where it should be allowed.
Can anyone shed any light where I am going wrong with my script? Many thanks
Here is my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
CustomField radioButton = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("10700");
if(radioButton == null)
return false
if(radioButton.getValue(issue).toString().equals("None"))
return false
else
return true
Hello,
Could you try it like this?
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customfield = customFieldManager.getCustomFieldObject("customfield_10700")
if (issue.getCustomFieldValue(customfield) == null) {
return false
} else {
return true
}
I tested on script console and it works.
Regards,
Elifcan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen,
I have a similar requirement as yours but when I tried it didn't work from.
I want to block transition when my custom field( Radio Button id is 14403) value is "No" I want a transition to happen only when a custom field value is "Yes".
Can you please help me where I am going wrong with my script? Many thanks
Here is the script I am using.
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customfield = customFieldManager.getCustomFieldObject("customfield_14403")
if (issue.getCustomFieldValue(customfield) == 'Yes') {
return false
} else {
return true
}
Thanks,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I want the opposite of the above. So if 'Yes' is selected in the radio button, do not allow the transition. My editor also does not like " import com.atlassian.jira.issue.MutableIssue;" saying it is not referenced when I include it in the script?
So I have:-
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.