I'm new in groovy script and i try to implement that the workflow status should be changed if a customer field is not empty. If i try to run the script in the groovy console it works as expected but not as post function.
The validation result of the issueService.validateTransition return false but the ErrorCollection mint be empty and returns only the folowing
{code:java}
ERROR [ajp-nio-127.0.0.1-8009-exec-4]: [:]
{code}
Here is my code.
{code:java}
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions
IssueService issueService = ComponentAccessor.getIssueService()
Integer actionId = 11 // The transition ID
log.debug("Type ="+issue.getIssueType().getName() +"")
if (issue.getIssueType().getName() != 'Schwachstelle aus PEN Test'){
return
}
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfSG = customFieldManager.getCustomFieldObject("customfield_14973");
def cfPM = customFieldManager.getCustomFieldObject("customfield_14974");
def sg=issue.getCustomFieldValue(cfSG);
def pm= issue.getCustomFieldValue(cfPM);
if((sg== null || sg=='') && (pm== null || pm=='')){
return
}
def workflowTransitionUtil = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
TransitionOptions transitionOptions = new TransitionOptions.Builder()
.skipConditions()
.skipPermissions()
.skipValidators()
.build()
IssueService.TransitionValidationResult result = issueService.validateTransition(currentUser,
issue.getId(),
actionId,
issueService.newIssueInputParameters(),
transitionOptions)
log.debug("Valid ="+result.isValid() +"")
log.debug("User ="+currentUser +"")
if (result.isValid()) {
issueService.transition(currentUser, result)
} else {
log.error( result.getErrorCollection().getErrors().toString())
}
{code}
can anyone help me finding the reason why?