I have defined:
in a different template I have the functions to gather the reference to my article; I wish to render an article with a given template.
...
#set( $templateId = 27121)
#set ($DDMTemplateLocalService = $serviceLocator.findService("com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLocalService"))
#set( $ddmTemplate = $DDMTemplateLocalService.getTemplate($templateId))
#if( ( $articleId != $reserved-article-id.data ) )
#set( $webContent = $journalContentUtil.getContent( $groupId, $articleId, $ddmTemplate.getPrimaryKey(), "view", "$locale", $xmlRequest ) )
#if ( $webContent )
<div>${webContent}</div>
#else
<div>Cannot use $templateName</div>
#end
#end
... the variable $webContent is always empty .
The reply comes from liferay forum https://www.liferay.com/community/forums/-/message_boards/view_message/45238697
"Method getContent of JournalContentUtil gets ddmTemplateKey as a third parameter, not ddmTemplateId. These are two different properties of DDMTemplate. If you use $ddmTemplate.getTemplateKey() instead of $ddmTemplate.getPrimaryKey(), it should work (of course if there are no other bugs)."
thanks to Krzysztof Gołębiowski