Hi,
A customer wants to be able to move issue (but everyone in the developer user is allowed) from every status to only a specified status("open" status for exp.) ?
How can i restrict to status(programatically or not)
I tried with the script listener. Action is Issue Moved.
Here is my code :
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.IssueInputParameters;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.workflow.TransitionOptions;
import com.atlassian.jira.workflow.WorkflowSchemeManager;
log.warn("issue moved");
log.warn("status : " + event.getIssue().getStatus());
log.warn("Issue Type : " + event.getIssue().getIssueType());
WorkflowSchemeManager workflowSchemeManager = ComponentAccessor.getWorkflowSchemeManager();
String wfName = workflowSchemeManager.getWorkflowName(event.issue.getProjectObject(), event.issue.getId().toString());
log.warn("wfName : " + wfName);
def openStatusTransitionID = 131;
def adminUser = ComponentAccessor.getUserManager().getUserByName("safak.sahin");
MutableIssue issue = (MutableIssue)event.getIssue();
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters inputParameters = issueService.newIssueInputParameters();
inputParameters.setStatusId("1").setIssueTypeId("6").setSummary("updated:" + issue.getSummary());
TransitionOptions transitionOptions = TransitionOptions.defaults();
transitionOptions.skipConditions();
transitionOptions.skipPermissions();
transitionOptions.skipValidators();
IssueService.TransitionValidationResult transitionValidationResult;
transitionValidationResult = issueService.validateTransition(adminUser, issue.getId(), openStatusTransitionID, inputParameters);
if (transitionValidationResult.isValid()) {
IssueService.IssueResult transitionResult = issueService.transition(adminUser, transitionValidationResult);
if (!transitionResult.isValid()) {
ErrorCollection errors = transitionResult.getErrorCollection();
errors.getErrorMessages().each{log.warn(it)};
errors.getReasons().each{log.warn(it)};
errors.getErrors().each{k,v -> log.warn("Key : " + k + " Value : " + v)};
}
} else {
ErrorCollection errors = transitionValidationResult.getErrorCollection();
errors.getErrorMessages().each{log.warn(it)};
errors.getReasons().each{log.warn(it)};
errors.getErrors().each{k,v -> log.warn("Key : " + k + " Value : " + v)};
}
And here is the log output:
2018-01-19 15:30:36,856 WARN [runner.ScriptRunnerImpl]: issue moved 2018-01-19 15:30:36,858 WARN [runner.ScriptRunnerImpl]: status : IssueConstantImpl[[GenericEntity:Status][sequence,45][statuscategory,4][name,Sales Approval][iconurl,/images/icons/statuses/generic.png][description,Sales Approve][id,10529]] 2018-01-19 15:30:36,858 WARN [runner.ScriptRunnerImpl]: Issue Type : IssueConstantImpl[[GenericEntity:IssueType][sequence,1][name,Bug][iconurl,/secure/viewavatar?size=xsmall&avatarId=12853&avatarType=issuetype][description,A problem which impairs or prevents the functions of the product.][style,null][id,1][avatar,12853]] This is the source issue Workflow not target ==>2018-01-19 15:30:36,881 WARN [runner.ScriptRunnerImpl]: wfName : TEST NP-MSU Workflow-deploymentsiz-w/o-DepUat 2018-01-19 15:30:36,884 WARN [runner.ScriptRunnerImpl]: The workflow operation with action id '131' does not exist in the workflow.
Script Runner Listener does not work because its start just before the move event.
Is there another way to do it?
I'm really stuck and customer want this no matter what.
This is old and came across it while searching for something else.
I haven't reviewed the code carefully I see 2 options to achieve forcing the status to Open for all Move operations
1) Scripted Listener like you proposed. But this requires that all of your possible target workflows must allow transition from ANY status to OPEN, so that you can detect and apply that transition to the issue.
2) Block the default MOVE operation using the hide UI element scriptrunner fragment (perhaps conditionally based on current project) and instead provide a workflow transition (from any status to itself) that will have all the move operation as part of a postfunction. Jira Workflow toolbox has a built-in Move Issue postfunction. Or you can script it yourself. This will allow you the ability to hard code any part of the move operation (or prompt for details using custom fields and transition screen) - Target Project, Target Issue Type, Target Status etc
You should be able to address this issue by modifying your workflows.
Check the "Allow all statuses to transition to this one" box on your required status.
Create a group for your customers and place a permission check on the transition to the relevant status to make sure they are in the relevant group.
You may need to modify your project permissions and/or place some additional permission checks on your other transitions, but that should be able to solve your use case.
Hope this help,
Tyler
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tyler,
Thanks for replying. "Allow all statuses to transition to this one" is already checked.
But that status is exist in target project workflow. What i need is no matter which status has been choosen on the move issue screen, when i move the issue it must be setted the Open status.
I think your suggestion did not meet my needs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you are looking for a way to force the workflow to the "Open" status whenever a customer selects any transition step in the workflow?
My initial suggestion would not solve for that problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not exactly like that.
When user move issue from one project to another, user choose a workflow status from the target projects workflow right?
Now what i want is ignore user's workflow status choice and after moving operation issue always should be setted Open status.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.