0

I am using Asset Publisher and need to dynamically get the articleId of the latest journal article published.

I am using in abstracts.jsp hook:

version=JournalArticleLocalServiceUtil.getLatestVersion(assetRenderer.getGroupId(), "14405");
journalArticle = JournalArticleLocalServiceUtil.getArticle(assetRenderer.getGroupId() , "14405",version);

I have hardcoded the articleId here. How do I avoid this??

Kindly help. Thanks.

irene
  • 37
  • 1
  • 9

1 Answers1

3

Use a dynamic query to get the latest Article from JournalArticleLocalServiceUtil maybe you can use ProjectionFactoryUtil.max("createDate"); to get the latest Date

DynamicQueryFactoryUtil.forClass(JournalArticle.class)  
  .add(ProjectionFactoryUtil.max("createDate"))  
  .add(PropertyFactoryUtil.forName("groupId").eq(new Long(groupId)));  
List results =JournalArticleLocalServiceUtil.dynamicQuery(query);`
Simon Grimm
  • 1
  • 2
  • 8
Tator
  • 566
  • 6
  • 21