-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Hello,
i need to block the creation of an issue if a custom field value is less than 1.
I tried with the attached 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.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.opensymphony.workflow.InvalidInputException;
import org.apache.log4j.Category;
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_13200")
def cFieldValue = issue.getCustomFieldValue(cField) as Integer
if (cFieldValue > 0){
log.debug("ERRORE, QUANTITA' NON DISPONIBILI");
throw "ERRORE";
throw new InvalidInputException("QUANTITA' NON DISPONIBILI");
return cFieldValue;
return false;
}
The log, due to its length, is attached to this request as a .txt file.
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,
Regards,
Luca
Metadata
Metadata
Assignees
Labels
No labels