Hello,
i need to block the creation of an issue if a custom field value is less than 1.
I tried with this code with no success, the custom field ID is: 13200.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.opensymphony.workflow.InvalidInputException
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def quantita_disponibili = customFieldManager.getCustomFieldObject("customfield_13200")
def cFieldValue = (int)issue.getCustomFieldValue(quantita_disponibili)
if (cFieldValue > 1) {
throw new InvalidInputException("Quantità non disponibili.");
}
That custom field is taken from another DB (linked via Elements) and it's the quantity of a particular item, if the quantity is less than 0 the ticket should throw an exception but it doesnt work as i would..
I'm putting this "Groovy inline script" in the validator the issue creation.
Thanks for your help,
Luca