how to store multifield nodes as JSON in aem 6.5 (coral 3) ? | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Ravi_Pampana
Community Advisor
Community Advisor
April 23, 2022

Hi,

 

Try adding composite as false 

 

prakashvb
prakashvbAuthor
Level 2
April 23, 2022

Hey thanks for reply but that way it's will be stored as an array like comma separated 

arunpatidar
Community Advisor
Community Advisor
April 25, 2022

Hi,

OOTB the coral multifield stoored values as node. You have to write your own logic to store the multifield as json but you can read it from Node as well. YOu can check some old thread with the same queries.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/coral-multifield-6-4-touch-ui-to-save-value-in-json/m-p/271650

 

Arun Patidar
prakashvb
prakashvbAuthor
Level 2
April 25, 2022

I have fixed by jqury dialog logic i will capture multifield data and concert into json and store into text field please refer below code 

 


console.log("client multifields....");
(function(document, $, ns) {
"use strict";
$(document).on("click", ".cq-dialog-submit", function(e) {
var attributelist =$("input[name='./fname']").attr("data-attribute1").split(",");

console.log("attributelist"+attributelist.size);
var parentlabel = "./"+ $("input[name='./fname']").attr("data-parentlabel");


var $formminmax = $(this).closest("form.foundation-form");

var field = $formminmax.find("[data-granite-coral-multifield-name='"+parentlabel+"']");
var totalLinkCount = field.children('coral-multifield-item').length;
var test = field.children('coral-Form-fieldwrapper').name;


var jsonObj = [];

for (var i = 0; i < totalLinkCount; i++) {
var item = {}
console.log("pp"+'itemXX'.replace('XX',i));

for (var j=0; j < attributelist.length; j++) {
var itemname = './bookdetailswithmap/item'+i+'/./'+attributelist[j];
item [attributelist[j]] =field.find($("[name='"+itemname+"']")[0]).val();
}
jsonObj.push(item);
}
var obj2 = {"parentlabel": jsonObj };
snippet.log(obj2.personalization.name);
$('.fnameclass').val(JSON.stringify(jsonObj));
});
})(document, Granite.$, Granite.author);

September 28, 2022

Thanks!, this is great help, Can you please share the component structure as well.