How to use script runner to modify workflow?

 

1 answer

1 accepted

0 vote

What do you mean by "modify workflow"?  

e.g.

  • Edit the workflow directly? 
  • Change the workflow scheme on a project?
  • Change a workflow scheme?
  • Control the flow a user follows within a workflow? 

Note that three of those are a potential nightmare that you probably don't want to do...

I need to write script to modify workflow. In the workflow, after certain steps I need to check condition, if the condition is true then perform some task etc. 

In short I need to implement algorithm in the workflow. I saw some groovy scripting. But could not understand how to implement algorithm using script to modify workflow? please help me.

I do not understand the objective. Do you want to modify the workflow or actually just create a workflow that works for your process?

My workflow already exists. I need to modify my workflow with set of statements like a script for example: my script is 1. Once issue status changed to "construction". (condition) if service request = request for change. 2. If condition fails, then switch to next state transition. 3. else if condition true, then check next condition if subtask=java 4.if condition fails then switch to next transition 5. else perform some task.

That's not modifying a workflow, that's automating a process, and it's not clear what you're trying to do, but I'll try to paraphrase it and explain what you might do. Issue status is a function of the workflow. So by "issue status changed to construction", you mean "Someone uses the transition that puts the issue into construction". Now, I think the (condition) you mention, but don't explain, means "I have a custom field called 'Service Request'. If the user has selected "Request for change" in that custom field, I don't want to leave the issue in 'construction', I want it to have some other status I'm not clear on your if/then/elses either, but they're not that important, because we're only looking at the basic idea of what you need to do. To do the second transition, you need the system to detect that case, decide which transition it needs to use, and then push the issue through it. The Script Runner does have an auto-transition function - see https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Fast-tracktransitionanissue but it might not be quite what you need.

See I will explain you., what you understand is correct. I have a custom field called service request and sub-task. If someone puts the issue in "construction", then workflow should follow some steps: 1. if (service request=request for change) is true, then go to step 3. 2. if (service request = request for change) is false, then go to step 7. 3. if (sub-task=cobol) is true, then go to step 5. 4. if (sub-task=cobol) is false, then go to step 7. 5. write some data to a attachment file. 6. save and close the attachment. 7.Now put the issue in "AAHO" phase.

Ahh, good. Then yes, you can use the script-runner's auto transition facilities to do this.

Can you explain in detail how to implement it with my example? because as there are two conditions needs to be checked. step 1 and step 3.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,307 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot