I need to set JSON to my form which is a bit complex. Actually, the additional user is added when somebody clicks on that button “Create Additional Portal User Account for this Customer”.
I want that when a JSON having those additional customers should be appended to this form.
It depends in what format you want to receive form data. You can write a custom method that collects data from the main form as well as the additional ones:
var formsData = {};
formsData.main= $$("customerDetailsForm").getValues();
formsData.extra = {};
var extras = $$("additionalCustomerAdd").getChildViews();
for(var i in extras)
formsData.extra[i] = extras[i].getValue();
console.log(formsData);
If I put a button in the sub-form to remove it, I can remove it. But a small problem I am facing is, when I set the values, it removes from view but getValues of the form contains the JSON in it(Press Next button after setValue and removing any view then count number of AdditionalPortalUserAccounts JSON in console ).