Tuesday, 2 July 2013

get custom field (expando table) value in velocity template

Hi all ,

First accessing service of liferay in velocity we have to enable serviceLocator.
You have to right below line to enable to servicLocator in portal-ext.properties file & restart server.

where to find portal-ext.properties click here.

journal.template.velocity.restricted.variables=


Now in template right below code to get particular user field value..


#set ($UserLocalService = $serviceLocator.findService('com.liferay.portal.service.UserLocalService'))
#set ($companyId = $getterUtil.getLong($request.theme-display.company-id))
#set ($userId = $getterUtil.getLong($request.theme-display.user-id))

#set($Degree=$ExpandoValueService.getValue($companyId,"com.liferay.portal.model.User","CUSTOM_FIELDS","Degree",$usersId))

$Degree.getData()

It display the value of user degree custom field value.


If any query plz do comment or mail us at:
chiragmsc007it@gmail.com
mehdisunasara@gmail.com