Last active
June 13, 2023 17:01
-
-
Save marcosblandim/1a6fdc1c689c2f56ae3564f09bbfebfc to your computer and use it in GitHub Desktop.
Liferay: Get Journal Article's DDM Field value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.liferay.dynamic.data.mapping.storage.DDMFormFieldValue; | |
| import com.liferay.journal.model.JournalArticle; | |
| import com.liferay.journal.service.JournalArticleLocalServiceUtil; | |
| import com.liferay.portal.kernel.util.LocaleUtil; | |
| String fieldName = "field name"; | |
| Locale locale = LocaleUtil.getDefault(); | |
| boolean includeNestedDDMFormFieldValues = true; | |
| JournalArticle journalArticle = JournalArticleLocalServiceUtil.fetchJournalArticle(id); // change this to use the Journal Article you need | |
| Map<String, List<DDMFormFieldValue>> ddmFormFieldValuesMap = journalArticle.getDDMFormValues(). | |
| getDDMFormFieldValuesMap(includeNestedDDMFormFieldValues); | |
| String value = ddmFormFieldValuesMap.get(fieldName).get(0).getValue().getString(locale); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment