Fuiba Fuiba - 1 year ago 114
Java Question

Can I get Journal article resource UUID from article ID?

I have created a Liferay WCM structure with a field where the user enters the ID of an existing web content. I want to use that ID to get the resource UUID.

How can I accomplish this?

Answer Source

First of all locate JournalArticleLocalServiceUtil using $serviceLocator.findService method and then use getJournalArticle to get article by id, as following:

#set($articleId = xxx) here `xxx` is your `$articleId`
#set($articleService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"))
#set($article = $articleService.getJournalArticle($articleId))

Now, you can access all the properties of $article object:

#set($articleResourceId = $article.getArticleResourceUuid())
#set($articleUUId = $article.getUuid())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download