Is there any way to do this with script?
I am constantly getting error that it is not possible in the current state, even though I'm in the Open step. I have tried with reindexing issue after creation as well.
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = event.getIssue()
def reporter = issue.getReporter()
def upm = ComponentAccessor.getUserPropertyManager()
def propertySet = upm.getPropertySet(reporter)
if(propertySet.getString("jira.meta.Spam").equals("true")){
def workflowManager = ComponentAccessor.getWorkflowManager()
IssueService issueService = ComponentAccessor.getIssueService()
JiraWorkflow jiraWorkflow = workflowManager.getWorkflow(issue)
def issueIndexService = ComponentAccessor.getComponent(IssueIndexingService)
StepDescriptor oStep = jiraWorkflow.getLinkedStep(issue.getStatus());
List<ActionDescriptor> oActions = oStep.getActions();
for(ActionDescriptor oAction : oActions){
if(oAction.getName().equals("Spam")){
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
def validationResult = issueService.validateTransition(currentUser, (Long) issue.getId(), oAction.getId(), issueInputParameters)
log.warn validationResult.getErrorCollection()
if(validationResult.isValid()){
issueService.transition(currentUser,validationResult)
}
}
}
}
This works well for issue updated event, just not on create.
I have managed to get the wanted functionality!
Instead of using custom made script, use fast-track transition an issue script.
in the end only code needed to accomplish the check is this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserPropertyManager
def upm = ComponentAccessor.getUserPropertyManager()
def reporter = issue.getReporter()
def propertySet = upm.getPropertySet(reporter)
propertySet.getString("jira.meta.Spam").equals("true")
I don't understand why this is not possible with regular script but hey!
Are you sure, that user is allowed to perform this transition?
You should check conditions and validators.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
yes this is my local testing JIRA, I am both administrator and service desk team, using the default permission scheme.
There is nothing(validators,conditions) on the transition except one additional post function setting the resolution.
As I said, it is working fine on update, just not on create.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had the same exact issue. I wrote a listener that worked on Update but not on Create. Then I wrote a custom post-function and that does the same thing that a 'fast-track transition' does. My custom post-function returned error:
[It seems that you have tried to perform a workflow operation (<name of action>) that is not valid for the current state of this issue (ABC-123). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]
That isn't the likely cause at all. Whatever the cause, Deleted user is correct, it works when using an Adaptavist 'fast-track transition'.
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.