Trying to write a Groovy script for my workflow post function to change assignee

It says "Only execute this post-function if the following Groovy expression returns true"

I am trying write a script to change the assignee based on what a user chooses in a custom field, but I am not having any luck. I figure my script is wrong and I cannot find any information to help my particular case. I had something like this:

if(issue.get("Issue Source").getName() == "Agent Portal"){
return true;
} else {
return false;
}

 

I got it to work doing this:

 

if(issue.get("customfield_18173")
== "Desktop" || issue.get("customfield_18173") ==
"Support"){
return true;
else {
return false;
}

 

However, I want this to happen on creation, so I put it on the Create transition (the first one), but it is not working.

7 answers

1 accepted

Accepted Answer
0 votes

I got it to work doing this:

 

if(issue.get("customfield_18173")
== "Desktop" || issue.get("customfield_18173") ==
"Support"){
return true;
else {
return false;
}

Also, make sure the post function is the first in the order.

Hi Cole,

I thing your tag and the title of your questions are inconsistent....

What do you mean?

Sorry, I I misread your question. Maybe this answer is of any help https://answers.atlassian.com/questions/272403 ?

I got it to work doing this:

if(issue.get("customfield_18173")
== "Desktop" || issue.get("customfield_18173") ==
"Support"){
return true;
} else {
return false;
}

However, I want this to happen on creation, so I put it on the Create transition (the first one), but it is not working.

Which post-function are you using? And where did you put the post-function in the list?

I solved it by moving the post function to the first in the order. Thank you for your help!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,857 views 2 7
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