Fuiba Fuiba - 15 days ago 5x
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?


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())