Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Render Custom field value in plugin template

Neil Dixon November 22, 2019

Hello 

I have a plugin that is displaying a vm template that is supose to display a customfield value.  I've looked through the other questions and answer online and the solutions are not working for me.  I am running Jira 7.13.5

The error I'm getting is Nullpointer exception on the set $cfVal line.

I've ensured the test data has no NULLs

I also tried just displaying: $customFieldManager.getCustomFieldObject("customfield_15206").getName()

but this only resulted in $customFieldManager.getCustomFieldObject("customfield_15206").getName() being display and not the value it was as if this value was not parsed by the template.

 

#disable_html_escaping()
#foreach( $issue in $issues )
#if ($issue.getCustomFieldValue($customFieldManager.getCustomFieldObject("customfield_15206")))
#set($cfVal = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject("customfield_15206")))
$cfVal
#else
No Value
#end
#end

 Is there any thing extra need in the main Java function before rendering the template or in the plugin.xml?

Any help would be apperciated.

Thanks,

Neil

 

 

1 answer

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 23, 2019

Hi @Neil Dixon 

To use customFieldManager object in vm template, you need to add it to velocity context in your servlet code.

Are you  sure, you are putting an instance in server side?

Neil Dixon November 25, 2019

Hi

Thanks for the help.

I added 

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
context.put("customFieldManager", customFieldManager);

To my servelt code and it is working.

Neil

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 25, 2019

I'm glad that it helps.

Suggest an answer

Log in or Sign up to answer