May 10, 2020
Estimated Post Reading Time ~

Use JS to Read Multifield Values

“use strict”;
use(
[“/libs/wcm/foundation/components/utils/AuthoringUtils.js”],
function (AuthoringUtils) {
var itemList = granite.resource.properties[“items”];
var itemArray = [];
if(itemList != null) {
if( itemList.getClass().isArray() ) {
for (var i = 0, l = itemList.length; i < l; i++) {
var temp = JSON.parse(itemList[i]);
itemArray.push(temp.text);
}
}
else {
var temp = JSON.parse(itemList);
itemArray.push(temp.text);

}
}
return {
itemArray : itemArray
};
});


By aem4beginner

1 comment:

  1. You can also look at this approach as well - https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/coral-ui-multifield-in-aem-6-3-sightly-js-use-api/m-p/289270/highlight/true#M17657

    ReplyDelete

If you have any doubts or questions, please let us know.