ADT Template - fetch DDMTemplate by name
Problem : sometimes you may need to access DDMTemplate in the asset publisher template, you know it’s name and you need to fetch it by name, but, unfortunately, there is no such service for that - you can fetch it only by templateKey: public DDMTemplate getTemplate( long groupId, long classNameId, String templateKey) As templateKey is generated automatically - it’s not a good idea to hard-code it directly in ADT. Solution : here is an FTL function, which finds the required DDMTemplate in Global scope using the template name: <#function getDDMTemplateByName templateName > <#assign ddmTemplateLocalService = serviceLocator . findService ( "com.liferay.dynamic.data.mapping.service.DDMTemplateLocalService" ) /> <#assign companyLocalService = serviceLocator . findService ( "com.liferay.portal.kernel.service.CompanyLocalService" ) /> <#assign portalUtil = staticUtil [ "com.liferay.portal.ker...