Skip to content

Instantly share code, notes, and snippets.

@marcosblandim
Last active June 13, 2023 17:01
Show Gist options
  • Select an option

  • Save marcosblandim/1a6fdc1c689c2f56ae3564f09bbfebfc to your computer and use it in GitHub Desktop.

Select an option

Save marcosblandim/1a6fdc1c689c2f56ae3564f09bbfebfc to your computer and use it in GitHub Desktop.
Liferay: Get Journal Article's DDM Field value
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