function buildAttributes() {
  for (i = 1; i < parseInt(array.settings.numberHeroUsers) + 1; i++) {
    var heroId = '#hero-0' + i;
    var row = {
      "user": {
        "id": $(heroId + '-name').val(),
        "attributes":{
          "emailAddress": $(heroId + '-email').val(),
          "sfmcContactKey": $(heroId + '-id').val(),
          "dateFirstSeen": new Date($(heroId + '-date').val()),
          "dateJoined": new Date($(heroId + '-joined').val()),
          "dateLastSeen": new Date($(heroId + '-last-seen').val()),
          "autoGenerate": false
        }
      }
    }
    // add any product attributes specified
    if($(heroId + '-auto-generate').is(':checked')){
      row.user.attributes.autoGenerate = true;
      var pickedItems = pickItems($(heroId + '-product').val());
      row.user.attributes.items = pickedItems;
      row.user.attributes.category = pickedItems[0].category;
    }

    // add any additional attributes specified
    $(heroId + '-attributes').children('.slds-col').each(function() {
      var field = $(this).find('.slds-size_1-of-3').find('input').val();
      var value = $(this).find('.slds-size_7-of-12').find('input').val();
      row.user.attributes[field] = value;
    });
    // add flag for anonymous profile creation
    row.user.attributes["hasAnon"] = $(heroId + '-anon-flag').is(':checked') ? true : false;
    array.users.push(row);
  }
}
// Function to build hero attribute array
Function to build hero attribute array
Function to build hero attribute array
function buildAttributes() {
  for (i = 1; i < parseInt(array.settings.numberHeroUsers) + 1; i++) {
    var heroId = '#hero-0' + i;
    var row = {
      "user": {
        "id": $(heroId + '-name').val(),
        "attributes":{
          "emailAddress": $(heroId + '-email').val(),
          "sfmcContactKey": $(heroId + '-id').val(),
          "dateFirstSeen": new Date($(heroId + '-date').val()),
          "dateJoined": new Date($(heroId + '-joined').val()),
          "dateLastSeen": new Date($(heroId + '-last-seen').val()),
          "autoGenerate": false
        }
      }
    }
    if($(heroId + '-auto-generate').is(':checked')){
      row.user.attributes.autoGenerate = true;
      var pickedItems = pickItems($(heroId + '-product').val());
      row.user.attributes.items = pickedItems;
      row.user.attributes.category = pickedItems[0].category;
    }
    $(heroId + '-attributes').children('.slds-col').each(function() {
      var field = $(this).find('.slds-size_1-of-3').find('input').val();
      var value = $(this).find('.slds-size_7-of-12').find('input').val();
      row.user.attributes[field] = value;
    });
    row.user.attributes["hasAnon"] = $(heroId + '-anon-flag').is(':checked') ? true : false;
    array.users.push(row);
  }
}
function buildAttributes ( ) { for ( i = 1 ; i < parseInt ( array . settings . numberHeroUsers ) + 1 ; i ++ ) { var heroId = '#hero-0' + i ; var row = { "user" : { "id" : $ ( heroId + '-name' ) . val ( ) , "attributes" : { "emailAddress" : $ ( heroId + '-email' ) . val ( ) , "sfmcContactKey" : $ ( heroId + '-id' ) . val ( ) , "dateFirstSeen" : new Date ( $ ( heroId + '-date' ) . val ( ) ) , "dateJoined" : new Date ( $ ( heroId + '-joined' ) . val ( ) ) , "dateLastSeen" : new Date ( $ ( heroId + '-last-seen' ) . val ( ) ) , "autoGenerate" : false } } } if ( $ ( heroId + '-auto-generate' ) . is ( ':checked' ) ) { row . user . attributes . autoGenerate = true ; var pickedItems = pickItems ( $ ( heroId + '-product' ) . val ( ) ) ; row . user . attributes . items = pickedItems ; row . user . attributes . category = pickedItems [ 0 ] . category ; } $ ( heroId + '-attributes' ) . children ( '.slds-col' ) . each ( function ( ) { var field = $ ( this ) . find ( '.slds-size_1-of-3' ) . find ( 'input' ) . val ( ) ; var value = $ ( this ) . find ( '.slds-size_7-of-12' ) . find ( 'input' ) . val ( ) ; row . user . attributes [ field ] = value ; } ) ; row . user . attributes [ "hasAnon" ] = $ ( heroId + '-anon-flag' ) . is ( ':checked' ) ? true : false ; array . users . push ( row ) ; } }
Function to build hero attribute array
Function to build hero attribute array
// add any product attributes specified // add any additional attributes specified // add flag for anonymous profile creation