It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Render Custom field value in plugin template

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

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?

Hi

Thanks for the help.

I added 

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

To my servelt code and it is working.

Neil

I'm glad that it helps.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you