CONDITIONS FOR WORKFLOW STEPS USING GROOVY SCRIPT

import com.atlassian.jira.component.ComponentAccessor

import java.sql.Timestamp

if (issue.getIssueType().getId() == "193") {
   if (issue.getWorkflowId == "<to check the workflow step id... what to insert here? and where to get it?>") {
      issue.setDueDate(new Timestamp((issue.dueDate + 3).time)) // set due date
   }

  if (issue.getWorkflowId == "<to check the workflow step id... what to insert here? and where to get it?>") {
      issue.setDueDate(new Timestamp((issue.dueDate + 7).time)) // set due date
   }
}

 

This groovy script will check for conditions by the workflow step id. How can I do so? Can anyone show me the code? Urgent. Need help ASAP. Thanks in advance.

1 answer

0 vote

That's going to be hard work if I remember the API correctly.

Why don't you just use two scripts, one on each post-function?

I thought of making it all in one script because I might need to add more codes for different days for each workflow steps.

If there's like 10 set of different days, that would be 10 scripts.

Which one is the best solution for this matter? If the one with conditions is the best, if you don't mind show me a sample of the code.

What would you suggest, Sir?

Thank you.

Cam.

Ok, if you use the id's, you'll need some (potentially unpleasant) code to find them.

I'd take a different route.  If you wrote 10 scripts and saved them as files in the scripts directory, you could use them repeatedly without thinking about transtion ids.  You'd say "use script add-4-days for this transition" and for the next one "use script add-6-days", and for a third, reuse add-4-days.  It'll keep your scripts very short and simple.

Another option is a bit longer - you could use a single script that reads a transition property that you add to transitions, which is a lot easier to get to in a post-function than the id.  Also means one script keeps it really simple!

Hi Sir,

Oh, I see. And if I may ask, could you provide and show me the code for it?

As I'm not really familiar with it.

I appreciate if you could lend me a hand.

Thank you.

Cam.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

71 views 0 5
Read article

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