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?
Why not write a groovy condition along with using the fast track transition for this?
In your condition, you build the issue type part with the and condition that the custom fields are not empty and when this is fulfilled, perform a fast-track transition to the intended status,
thx for your quick response.
But if i'm not wrong the fast-track transition is a built in part of the Script Runner Pluing and we are using only the MyGrooy Plugin.
I wrote another transition function that works. However, this function is not called after the issue has been created but as a post function to change the status of the sub tasks when the parent task changes to a certain status.
Or am I wrong here and you can give me an example for your explanation?
Best regards
Hannes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Two days spent with my new favorite plugin, some research on the internet and my problem was solved :-)
A fast-track transition exemple ist bundelt with the MyGroovy Plugin in the admin script section
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.