Legacy Knowledge Base
Published Jun. 30, 2025

Getting the value chosen by user in a 'Select From List' field

Written By

Sergio Alonso

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • How to get the value from the options added in a 'Select From List' field? We are getting the reference (i.e. ["Option37425674"]) instead of the value chosen by the user.

Environment

  • Quarterly Release

Resolution

  • Following example can be used as reference (it is a Widget Template of type Search Results Template):
<#if entries?has_content>
<#list entries as entry>
<#if entry.getClassName() == "com.liferay.journal.model.JournalArticle" >
<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
<#assign journalArticle = journalArticleLocalService.getLatestArticle(entry.getClassPK())/>
<#assign ddmStructure = journalArticle.getDDMStructure() />
<#assign ddmForm = ddmStructure.getDDMForm()/>
<#assign ddmFieldLocalService = serviceLocator.findService("com.liferay.dynamic.data.mapping.service.DDMFieldLocalService")/>
<#assign ddmFormValues = ddmFieldLocalService.getDDMFormValues(ddmForm, journalArticle.getId()) />
<#assign ddmFormFieldValues = ddmFormValues.getDDMFormFieldValues() />

<#list ddmFormFieldValues as fieldName>
<#assign ddmFormFieldOptions = fieldName.getDDMFormField().getDDMFormFieldOptions() />
<#assign optionsValues = ddmFormFieldOptions.getOptionsValues() />
<#assign options = ddmFormFieldOptions.getOptions() />

<#list optionsValues as optionValue>
<#if fieldName.getFieldReference() == 'Select78866849'>
<#if optionValue == fieldName.getValue().getString(locale)?remove_beginning("[\"")?remove_ending("\"]") >
<#list options as k, v>
<#if optionValue == k >
Option ${fieldName.getValue().getString(locale)} has ${v.getString(locale)} as value
</#if>
</#list>
</#if>
</#if>
</#list>
</#list>
</#if>
<p>&nbsp;</p>
</#list>
</#if>

 

 

 

Did this article resolve your issue ?

Legacy Knowledge Base