[Groovy] How to Check custom field validation in Jira groovy script

How to Check custom field validation in Jira groovy script

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.opensymphony.workflow.InvalidInputException

/** * Created by OzdemirCe on 19.02.2016. */
log.error("ece:: Start Validation abc");
MutableIssue myIssue = issue;
def cfA = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("A");
def cfB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("B");
def cfC = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("C");
if (cfA == null || cfB == null || cfC == null || cfA.getValue(myIssue) == null ||
        cfB.getValue(myIssue) == null || cfC.getValue(myIssue) == null ){
    return invalidInputException = new InvalidInputException("Validation failure a ile b nin toplami b olmalidir");
}

int  aValue = (int)cfA.getValue(myIssue);
int  bValue = (int)cfB.getValue(myIssue);
int  cValue = (int)cfC.getValue(myIssue);
int  sumVal = aValue+bValue;

if( sumVal != cValue ) {
    return invalidInputException = new InvalidInputException("Validation failure a ile b nin toplami b olmalidir");
}
log.error("ece:: End Validation abc");

Yorumlar

Bu blogdaki popüler yayınlar

Bir Yazılımcının karşılaşabileceği Mülakat Soruları Karşılaştıklarım

[Java] Append Nedir

WebSocket Nedir?