Condition to check if user in custom field is also the reporter

I have a post function on create to copy the value from "Hiring Manager" (a single user picker custom field), to the "Request Participants" field for JIRA service desk.

This post function works beautifully, as long as the hiring manager is not also the reporter of the issue, as reporters are automatically added as "Request Participants".

Since hiring managers tend to be reporters quite often, I wanted to make this a conditional execution, where this post-function on runs when a condition returns true. I have a similar condition on another workflow post-function working, however I cannot seem to get this one to work.

Without any kind of condition validator to tell me if the expression is returning true or false, I'm not sure what to do next. 

I currently have the condition written as:

issue.get("customfield_15480")!=issue.get("reporter")

 

Can someone help point me to where my mistake is in my syntax?

7 answers

1 accepted

Solved it! Below is the proper syntax in case any one else has any of these issues:

!issue.get("customfield_15480").getName().equals(issue.get("reporter").getName())

I have been able to determine that part of my issue is due to the data not truly matching. 

issue.get("reporter") returns

username

issue.get("customfield_15480") returns

username(username)

The custom field is a single user picker field, just like reporter. How can I get the outputs to match?

Ok, found some more info and updated my condition to

issue.get("customfield_15480").getName()!=issue.get("reporter")
log.error("Conditional Execution" + issue.get("customfield_15480").getName() + issue.get("reporter"))

The log file now shows

ERROR jtillett 1028x3177582x4 iyq99u /secure/QuickCreateIssue.jspa [jmwe.plugins.functions.CopyValueFromOtherFieldPostFunction] Conditional Executionjtillettjtillett:3
2016-05-12 17:08:20,632 http-bio-8080-exec-14009 ERROR jtillett 1028x3177582x4 iyq99u  /secure/QuickCreateIssue.jspa [jmwe.plugins.functions.CopyValueFromOtherFieldPostFunction] Unable to copy value from 'Hiring Manager' to 'Request participants'
java.lang.NullPointerException

So if the log file says the output of either side of the != are both equal to jtillett only, and the post function is only supposed to fire if the condition is TRUE, and jtillett!=jtillett is a false statement, then why is it still trying to run with a false condition?

0 vote

This is not Script Runner, so I'll remove that plugin tag. 

My mistake, I thought all the groovy stuff came from the script runner plugin

Is there a way to bump this for help?

0 vote

I would just advise you to put the correct plugin's tag on the question, because the developers don't trawl through every single question on the offchance it's about their plugin.

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 Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

135 views 1 10
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