Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Any scripts available to transition through workflow for updating issue to any status

Hi,

I am trying to change status of an issue programmatically. since there are no direct transition for some statuses, i have to transition through all available transitions from the initial status. This is bit tricky(similar to travelling sales person algorithm). Trying to find some optimal solution for this.

I could see that below code is been used in Jira CSV importer plugin. I tried it but doesn't help if there is no direct transition available to my desired target status.

JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issueResult.getIssue());
StepDescriptor linkedStep = workflow.getLinkedStep(status);
 Collection wfCurrentStepCollection = CoreFactory.getGenericDelegator().findByAnd("OSCurrentStep",
 EasyMap.build("entryId", issueResult.getIssue().getLong("workflowId")));
 if ((wfCurrentStepCollection != null) && (!wfCurrentStepCollection.isEmpty())) {
 GenericValue wfCurrentStep = (GenericValue) wfCurrentStepCollection.iterator().next();
 if (linkedStep != null) {
 wfCurrentStep.set("stepId", Integer.valueOf(linkedStep.getId()));
 wfCurrentStep.store();
 }
 }
 issueResult.getIssue().setStatusId(request.getStatusId());
 issueResult.getIssue().store();

 

besides, some of the functions are deprecated here. 

eg: CoreFactory.getGenericDelegator() and issueResult.getIssue().store()

Any help would be much appreciated!

Thanks.

1 answer

0 votes

You must not just "set" the status.  That is only appropriate when creating new issues, it does not work for existing ones.

You are going to have to tackle your travelling salesman problem and work out an optimal route through the workflow to your desired point and issue a number of transitions to get there.

Fortunately, in this case, you don't have the travelling salesmen problem.   You're not actually trying to traverse all points, you probably want the shortest route, so Dijkstra's algorithm can be used (and is simplified because the length of each trip is 1)

Thanks a lot. i will try to look at Dijkstra's for updating status.

This might be a complex task as i am looking at updating status of a bunch of issues in the range 3k-5k. 

Still curious to know if Jira native CSV Importer Plugin is also using the same algorithm. The Atlassian documentation  available for this is only till Jira 7.x version. Mine runs in 8.x

CSV imports create issues, so they can set the status.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you