function addData(fieldSets) {
  let tempObj = {};
  let jsonData = {};
  for (let i = fieldSets.length - ONE; i >= ZERO; i--) {
    const objName = fieldSets[i].name;
    let dataObject = {};
    dataObject[objName] = [];
    const rows = fieldSets[i].getElementsByClassName('slds-form-element__row');

    // for each row, make new object
    for (let j = rows.length - ONE; j >= ZERO; j--) {
      const innerInputs = rows[j].getElementsByTagName('input');

      // if there's one field per row,
      // check whether input name === fieldset name,
      // if so add input value to dataObject
      if (innerInputs.length === ONE && objName === innerInputs[ZERO].name) {
        dataObject[objName].push(innerInputs[ZERO].value);
      } else { // multi field row
        // loop through all fields per row
        for (let k = innerInputs.length - ONE; k >= ZERO; k--) {
          tempObj[innerInputs[k].name] = innerInputs[k].value;
        }

        dataObject[objName].push(tempObj);
      }

      tempObj = {}; // reset
    }

    // add fieldSet data to JSON
    jsonData[objName] = dataObject[objName];
  }

  return jsonData;
}
/**
 * Gets data from the supplied DOM elements.
 * @param {DOMElement} fieldSets The rendered field sets
 * @returns {Object} JSON representation of data in field sets
 */
Gets data from the supplied DOM elements.
@param {DOMElement} fieldSets The rendered field sets
@returns {Object} JSON representation of data in field sets
Gets data from the supplied DOM elements . @param { DOMElement } fieldSets The rendered field sets @returns { Object } JSON representation of data in field sets
function addData(fieldSets) {
  let tempObj = {};
  let jsonData = {};
  for (let i = fieldSets.length - ONE; i >= ZERO; i--) {
    const objName = fieldSets[i].name;
    let dataObject = {};
    dataObject[objName] = [];
    const rows = fieldSets[i].getElementsByClassName('slds-form-element__row');
    for (let j = rows.length - ONE; j >= ZERO; j--) {
      const innerInputs = rows[j].getElementsByTagName('input');
      if (innerInputs.length === ONE && objName === innerInputs[ZERO].name) {
        dataObject[objName].push(innerInputs[ZERO].value);
      } else { 
        for (let k = innerInputs.length - ONE; k >= ZERO; k--) {
          tempObj[innerInputs[k].name] = innerInputs[k].value;
        }
        dataObject[objName].push(tempObj);
      }
      tempObj = {}; 
    }
    jsonData[objName] = dataObject[objName];
  }
  return jsonData;
}
function addData ( fieldSets ) { let tempObj = { } ; let jsonData = { } ; for ( let i = fieldSets . length - ONE ; i >= ZERO ; i -- ) { const objName = fieldSets [ i ] . name ; let dataObject = { } ; dataObject [ objName ] = [ ] ; const rows = fieldSets [ i ] . getElementsByClassName ( 'slds-form-element__row' ) ; for ( let j = rows . length - ONE ; j >= ZERO ; j -- ) { const innerInputs = rows [ j ] . getElementsByTagName ( 'input' ) ; if ( innerInputs . length === ONE && objName === innerInputs [ ZERO ] . name ) { dataObject [ objName ] . push ( innerInputs [ ZERO ] . value ) ; } else { for ( let k = innerInputs . length - ONE ; k >= ZERO ; k -- ) { tempObj [ innerInputs [ k ] . name ] = innerInputs [ k ] . value ; } dataObject [ objName ] . push ( tempObj ) ; } tempObj = { } ; } jsonData [ objName ] = dataObject [ objName ] ; } return jsonData ; }
Gets data from the supplied DOM elements.
Gets data from the supplied DOM elements .
// for each row, make new object // if there's one field per row, // check whether input name === fieldset name, // if so add input value to dataObject // multi field row // loop through all fields per row // reset // add fieldSet data to JSON