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

Jeff Tillett
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2016

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

1 vote
Answer accepted
Jeff Tillett
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2016

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())
1 vote
Jeff Tillett
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2016

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?

1 vote
Jeff Tillett
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2016

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?

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2016

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.

0 votes
Jeff Tillett
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2016

Is there a way to bump this for help?

0 votes
Jeff Tillett
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2016

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

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2016

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events