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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Mission-critical battery manufacturer fulfills FAA software requirements with Commit Policy Plugin

EaglePicher Technologies is a leading manufacturer of battery systems for diverse industries like defense, aviation, space or medical. As they operate in highly regulated industries, keeping a clear ...

176 views 0 2
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