Accessing reporter value in Velocity template

Tim Shnaider October 9, 2011

Hi, I can't figure out how to access the reporter in a VM file.

During a create issue, I want to populate a specific custom field with the reporter, and don't know what to use in the VM file.

I can confirm that the 'Test text' is displayed, but I get empty strings for the following two lines.

#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)
#if ($customField.id == "customfield_10200" )
#set ($value = $textutils.htmlEncode($!reporter))
Test text
$!reporter.getClass().getName()<br/>
$!issue.reporterUser.getName()
#end
#userPicker ($action $customField.id $value false $null "" $canPerformAjaxSearch $ajaxLimit)
#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)

Thanks for your help, it's been driving me up the wall for hours.

4 answers

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.
October 9, 2011

issue.getReporter().getName() is correct, or issue.reporter.name. If that doesn't work make the reporter is populated. Also check your log for velocity errors.

Tim Shnaider October 10, 2011

Thanks, disabled the Velocity cache and enabled auto loading.

But have now decided that during a Create Issue all those values are null for a reason i.e. the issue hasn't been created yet, issue = null.

So now I'm looking to get the current user, and don't see anything obvious in the variables available in the context.

Tim Shnaider October 10, 2011

With the help of this snippet posted somewhere else, I've now sorted this out. Thanks for your help Jamie.

#foreach($p in $ctx.keySet().toArray())
$p.toString() - $ctx.get($p).getClass().getName().toString()<br/>

#end
$authcontext.getLoggedInUser().getName()

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.
October 10, 2011

Ah, sorry, missed the "create transition" bit of the question.

0 votes
Tim Shnaider October 9, 2011

I've also tried:

$!issue.getReporter().getName(), also returns empty string

$!issue.getClass().getName() returned ....IssueImpl

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.
October 9, 2011

getReporterUser returns a different type of user, although getName should work fine.

You don't need to restart, run with -Djira.dev.mode=true.

0 votes
Tim Shnaider October 9, 2011

Also tried following and all return empty, even though getReporterUser is supposed to be supported for 4.3+

$!issue.getReporterUser().getClass().getName()
$!issue.getReporterUser().getName()

Having to restart JIRA each time to test is getting rather tiresome...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events