function buildUsers() {
  array.users = [];
  var numHeroes = $('#hero-profiles').find('.slds-tabs_default__nav').find('.slds-tabs_default__item').length;
  for (i = 1; i < numHeroes; i++) {
    var id = $('#hero-'+i+'-profile').find('input[aria-label="attribute-id"]').val();
    var name = $('#hero-'+i+'-profile').find('input[aria-label="attribute-name"]').val();
    var emailAddress = $('#hero-'+i+'-profile').find('input[aria-label="attribute-email"]').val();
    var contactKey = $('#hero-'+i+'-profile').find('input[aria-label="attribute-key"]').val();
    var seenDate = new Date($('#hero-'+i+'-profile').find('input[aria-label="attribute-date"]').val());
    var joinDate = new Date($('#hero-'+i+'-profile').find('input[aria-label="attribute-joined"]').val());
    var lastDate = new Date($('#hero-'+i+'-profile').find('input[aria-label="attribute-last-seen"]').val());

    var row = {
      "user": {
        "id": id,
        "attributes":{
          "customerId": id,
          "fullName": name,
          "emailAddress": emailAddress,
          "sfmcContactKey": contactKey,
          "dateFirstSeen": seenDate,
          "dateJoined": joinDate,
          "dateLastSeen": lastDate
        }
      },
      "sessions": readHeroEvents($('#hero-'+i+'-profile'))
    }
    // add any additional attributes specified
    $('#hero-'+i+'-profile').find('div[aria-label="hero-custom-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;
    });
    // define anon id if required
    if($('#hero-'+i+'-profile').find('input[aria-label="attribute-anon-flag"]').is(':checked')==true){
      row.user.attributes["pairedId"] = createID(18)
    }
    array.users.push(row);
  }
}
// Function to build hero attribute array
Function to build hero attribute array
Function to build hero attribute array
function buildUsers() {
  array.users = [];
  var numHeroes = $('#hero-profiles').find('.slds-tabs_default__nav').find('.slds-tabs_default__item').length;
  for (i = 1; i < numHeroes; i++) {
    var id = $('#hero-'+i+'-profile').find('input[aria-label="attribute-id"]').val();
    var name = $('#hero-'+i+'-profile').find('input[aria-label="attribute-name"]').val();
    var emailAddress = $('#hero-'+i+'-profile').find('input[aria-label="attribute-email"]').val();
    var contactKey = $('#hero-'+i+'-profile').find('input[aria-label="attribute-key"]').val();
    var seenDate = new Date($('#hero-'+i+'-profile').find('input[aria-label="attribute-date"]').val());
    var joinDate = new Date($('#hero-'+i+'-profile').find('input[aria-label="attribute-joined"]').val());
    var lastDate = new Date($('#hero-'+i+'-profile').find('input[aria-label="attribute-last-seen"]').val());
    var row = {
      "user": {
        "id": id,
        "attributes":{
          "customerId": id,
          "fullName": name,
          "emailAddress": emailAddress,
          "sfmcContactKey": contactKey,
          "dateFirstSeen": seenDate,
          "dateJoined": joinDate,
          "dateLastSeen": lastDate
        }
      },
      "sessions": readHeroEvents($('#hero-'+i+'-profile'))
    }
    $('#hero-'+i+'-profile').find('div[aria-label="hero-custom-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;
    });
    if($('#hero-'+i+'-profile').find('input[aria-label="attribute-anon-flag"]').is(':checked')==true){
      row.user.attributes["pairedId"] = createID(18)
    }
    array.users.push(row);
  }
}
function buildUsers ( ) { array . users = [ ] ; var numHeroes = $ ( '#hero-profiles' ) . find ( '.slds-tabs_default__nav' ) . find ( '.slds-tabs_default__item' ) . length ; for ( i = 1 ; i < numHeroes ; i ++ ) { var id = $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-id"]' ) . val ( ) ; var name = $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-name"]' ) . val ( ) ; var emailAddress = $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-email"]' ) . val ( ) ; var contactKey = $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-key"]' ) . val ( ) ; var seenDate = new Date ( $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-date"]' ) . val ( ) ) ; var joinDate = new Date ( $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-joined"]' ) . val ( ) ) ; var lastDate = new Date ( $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-last-seen"]' ) . val ( ) ) ; var row = { "user" : { "id" : id , "attributes" : { "customerId" : id , "fullName" : name , "emailAddress" : emailAddress , "sfmcContactKey" : contactKey , "dateFirstSeen" : seenDate , "dateJoined" : joinDate , "dateLastSeen" : lastDate } } , "sessions" : readHeroEvents ( $ ( '#hero-' + i + '-profile' ) ) } $ ( '#hero-' + i + '-profile' ) . find ( 'div[aria-label="hero-custom-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 ; } ) ; if ( $ ( '#hero-' + i + '-profile' ) . find ( 'input[aria-label="attribute-anon-flag"]' ) . is ( ':checked' ) == true ) { row . user . attributes [ "pairedId" ] = createID ( 18 ) } array . users . push ( row ) ; } }
Function to build hero attribute array
Function to build hero attribute array
// add any additional attributes specified // define anon id if required