Hi All
Need your help on this script.
i am trying to validate a condition where, i have a issue "XYZ" , and under that issue sub task is there.
when i am trying to add another issue "PP" to "XYZ" , i need to put a validator on create screen, that if the sub task is in certain status and it has specific values , then it should return false or true , and based on that the transition will happen. the problem is its going to desired if block but it still allowing the transition to happen. can anyone help me on this?
added the code below.
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor ;
//import com.atlassian.jira.issue.MutableIssue ;
//import com.atlassian.jira.issue.fields.config.FieldConfig ;
//import com.atlassian.jira.issue.customfields.option.Options ;
//import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import org.apache.log4j.Level ;
import org.apache.log4j.Logger ;
def logs = Logger.getLogger("com.citi.jira.postFunction.BRParentLinkCheck")
logs.setLevel(Level.DEBUG);
logs.debug("Started Parent Link Verify For BR Changes : ----")
// Grab Current Issue
CustomFieldManager customFieldManager1 = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager();
def parentLinkField = customFieldManager1.getCustomFieldObjects(issue).find {it.name == "Parent Link"}
def parentLinkValue = issue.getCustomFieldValue(parentLinkField) as String
boolean pass = true
Issue PlanviewIssue = issueManager.getIssueObject("" + parentLinkValue);
//String planviewStatus = PlanviewIssue.getStatus().getName()
//def parentIssueName = PlanviewIssue.getIssueType().getName() as String
//logs.debug("printing parent Issue Name : ----" + parentIssueName)
if(parentLinkValue != null){
// if(PlanviewIssue.getIssueType().getName() == "Planview"){
logs.debug("Entering into if issue type is Planview Manas : - ---- - - - - - ")
def allSubTask = PlanviewIssue.getSubTaskObjects()
logs.debug("Prinitng All Sub tasks Under Planview On Create: ---" + allSubTask)
allSubTask.each{ i ->
logs.debug("Printing Sub Task Issue Under Planview -->>" + i.getIssueType().getName())
if(i.getIssueType().getName() == "Approval Sub-task"){
logs.debug("Printing Status For each Sub Task Issue Under Planview -->>" + i.getStatus().getName())
String status = i.getStatus().getName()
logs.debug("Status Printing :---" + status)
CustomField approval = customFieldManager.getCustomFieldObjects(i).find {it.name == "Approval type"}
String approve = i.getCustomFieldValue(approval) as String
logs.debug("Printing Approval type Field value : --->>" + approve)
if(status != "Open" && approve == "BR"){
logs.debug("Entering 1st if block : --->>")
return pass = false
logs.debug("Entering 1st if block pass value : --->>" + pass)
}else if(status == "Open" && approve == "BR"){
logs.debug("Entering else if block : --->>")
pass = true
}else{
logs.debug("Entering else block : --->>")
pass = false
}
}
else pass = false
logs.debug("Entering issue type else block : --->>")
logs.debug("Entering issue type else block : --->>" + pass)
return pass
}
}else return pass
/* }else if(parentLinkValue == null){
return pass
}*/
Any help will be appreciated
Regards
Manas