Issue
- I'm configuring a search results ADT for a custom Object. By default I can choose, in the available variables, the title, author, etc. But I need to access custom fields of the Object as well.
Environment
- Liferay DXP 7.4
Resolution
- Search for the service endpoint in the API console ( /o/api ) on a web browser corresponding to the Object entity.
- In the ADT make a call to the rest service using the "restClient" and the classPK as Id.
<#if entries?has_content>
<#list entries as entry>
<#assign myobject = restClient.get("/c/myobjects/${entry.getClassPK()}")>
field1: ${myobject.field1} <br>
field2: ${myobject.field2} <br>
field3: ${myobject.field3} <br>
</#list>
</#if>
Additional Information
- Here is a recorded session with a live demo by Alejandro Tardín that explain perfectly how to implement this solution:
https://liferay.dev/twentyfour#Put%20your%20templates%20at%20REST
Subscriber Exclusive Content
A Liferay Enterprise Subscription provides access to over 1,500 articles that include best practices, troubleshooting, and other valuable solutions. Sign in for full access.
Sign In