Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update status using transition using java API?

Ramesh Lakshmanasamy July 20, 2018

I need to update issue using JAVA API.This is only possible via transition id.Please can you put some java code.

2 answers

1 vote
Tansu Akdeniz
Community Champion
July 20, 2018

Hi @Ramesh Lakshmanasamy,

Please take a look at: 

Example code;

WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);

Map params = new HashMap();
String comment = "abc"
params.put(IssueFieldConstants.COMMENT, comment);

workflowTransitionUtil.setIssue(issue);
workflowTransitionUtil.setUserkey(userKey);
workflowTransitionUtil.setAction(111);
workflowTransitionUtil.setParams(params);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
Harsh Dubey-Admin June 10, 2019

It doesn't work.

0 votes
Christian_Schönert August 28, 2019

Since I was on the search myself, I found this solution (tested with Jira 8.3.0 and 8.3.1):

 

IssueService.IssueResult transResult;
IssueInputParameters issueInputParameters = new IssueInputParametersImpl();

TransitionValidationResult validationResult =
issueService.validateTransition(workflowuser, issue.getId(), actionDescriptor.getId(), issueInputParameters);

if (validationResult.isValid()) {
transResult = issueService.transition(workflowuser, validationResult);
}

 

What you have to figure out yourself is how to get at the JiraWorkflow. I, for example, extract the List by the following:

Collection<JiraWorkflow> workflows = workflowManager.getActiveWorkflows();

 

where I iterate all workflows and compare to the searched workflow name. From there on you can go through all actions (.getAllActions()) which give you the transition IDs.

My problem is, and I hope maybe someone else can answer it: How do you make a transition comment?

 

This:

issueInputParameters.setComment("TestComment");

 always gives me the validation error that I'm not permitted to add a comment to this issue, although the workflow user is admin and creator of the actual issue.

 

Regards

Chris

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events