issue get reporter in postfunction

I'm searching for syntax for issue get Reporter in postfunction.


I tried this

if(issue.getReporter() == 'xy'); { return true; }

if(issue.get('reporter') == 'xy'); { return true; }


It doesn't work.


How to write this condition in postfunction?


Thanks a lot.





6 answers

Try this:

You can also get the user key the same way.

The right expression is in this Context:

if (issue.get("reporter").getUsername() == 'UserID')


return true;



That works.

Postfunction "Set Field Value to constant or Groovy expression Function" is from Addon "JIRA Misc Worklflow Extensions".

Answer from Support was this

"The "issue" variable holds a proxy to the Issue object, and only supports the "get" method. If you want to use JIRA's Issue object, you need to use the issueObject variable instead.
To get the reporter, you can use: issue.get("reporter"). That returns an ApplicationUser object, on which you can call "getUsername()" to get the username."

No doesn't work


I also tried this

if(issueObject.getReporter(). == 'xy'

The same doesn't work

0 votes

If you want to use == to compare things, they usually need to be the same type of object.  Your code compares a "user" object with a string, which probably isn't going to work.  Either extract the name or login from the user to compare it, or make the string into a proper user.

In other words, something like


If your code is now structurally correct, as we've all talked through, my next question is "are you comparing the right thing"?

A user object has many attributes - I've picked on getName() as probably the best one, but it might not be what you're comparing.

Let's take "confused Bob" as an example.  They log in as alice, have an email address of and a display name of Charlie Smith.  For Confused Bob here, getName will say "alice", but getDisplayName will give you "Charlie Smith".  I don't know what your XY string is trying to match...

I tried getName() with display name (real user in system, display name separated by space). Isn't it right?

I think the display name is not the best one. I think the Username would be good to compare or the mail-adress. But I don't know what JIRA writes in the field "reporter" (on screen you see the display Name in Issue).

No, see the end of my previous comment.

JIRA usually gives you the display name when it displays a user, but I think your instinct to use the login id is better than the display name (it can change, but rarely does)

I understand it with display name, user name and so on. But it doesn't matter which one I use, the result ist the same  not true.

Ok, could you add some logging - specifically, what does this dump into the log?

System.out.println ( issue.getReporter().getName() )

return true


Are you getting any error? What is the response?

Your second approach is right!

if (issue.getReporter().getName() .equals("Bob Smith")

But, the error is the braces of if condition is not closed and there is a space before .equals.

if (issue.getReporter().getName().equals("Bob Smith"))

Try this now.

With braces or not unfortunately it doesn't work.

Please compare and find your mistake. smile


With space it also doesn't work. It's a Groovy script.

Alright! Where are you trying this code now?

Please share a screenshot.

Cool! Referring to @Nic Brough [Adaptavist]'s latest comment, try this script to get the right user name instead of the display name.

return issue.getReporter().getName()

Take the output of this and set it in the if condition's comparison.

Have you tried this?

Yes I've tried doesn't work in this context it seems for me.


return issue.getReporter().getName() == 'username'
return issue.getReporter().getName().equals('username')

Alright. Try this one now.

Go to JIRA Administration -> User Management -> Users. Search for your reporter. Click on Edit. It appears as this.


Now consider the Username (Not the full name). Try the below script again. 

return true

It should work!

Yes ist should but i does not work.

So it is. I think in in the context of postfunction "Set field Value to constant or Groovy expression" there are some things that are special (but I don't know). Fact is this expression in different variants does not work.



I understand I tried this

if (issue.getReporter().getName() == ("Bob Smith")

if (issue.getReporter().getName() .equals("Bob Smith")

Doesn't working.












Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,084 views 4 9
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