CAFNW

function emailButton(button, emails, label) {

		let bccArtists = emails.filter((v, i, a) => a.indexOf(v) === i).join('%3B%20');
			
		let mailto = 'mailto:?bcc=' + bccArtists;

		button.html = '<h6><a href=' + mailto +' target="_blank" rel="noopener noreferrer" align="center">'+ label +'</a></h6>';
	
}
emailFetch('pafApplication', vendors, 'emailAddress')
		.then(returnedData => {
			console.log('[dataRefresh] returned Data from emailFetch is', returnedData)

			emailButton($w('#emailBtn'), returnedData.thisYearEmails, 'Email All Applicants')
			emailButton($w('#emailAcceptedBtn'), returnedData.thisYearApprovedEmails, 'Email Accepted Applicants')
			emailButton($w('#emailAllBtn'), returnedData.allEmails, 'Email All Applicants')
			emailButton($w('#emailAllAcceptedBtn'), returnedData.allApprovedEmails, 'Email Accepted Applicants')
		})
<table></table>
<script type="text/javascript">

function generateTableHead(table, data) {
  let thead = table.createTHead();
  let row = thead.insertRow();
  for (let key of data) {
    let th = document.createElement("th");
    let text = document.createTextNode(key);
    th.appendChild(text);
    row.appendChild(th);
  }
}

function generateTable(table, data) {
  for (let element of data) {
    let row = table.insertRow();
    for (key in element) {
      let cell = row.insertCell();
      let text = document.createTextNode(element[key]);
      cell.appendChild(text);
    }
  }
}

window.onmessage = (event) => {
    if (event.data) {
    	let table = document.querySelector("table");
       let rows = event.data;
       let head = Object.keys(rows[0])
       generateTableHead(table, head)
		generateTable(table, rows)
    }
  };
  
  //...
  
</script>
export function fieldsUpdate(group) {
    let update = {}

	console.log('fieldsUpdate group is', group.children)

		group.children.forEach(field => {
		if (field.value !== null) {
			if (field.inputType === 'number') {
				update[field.id] = Number(field.value)
			} else if (field.fileType !== undefined) {
				field.value = null
			} else if(field.type === '$w.Checkbox') {
				update[field.id] = field.checked
			} else {
				update[field.id] = field.value
			}	
		}
		})

    return update
}
export function uploadHelper(field, dataset, dbField) {
	if (field.value.length > 0) {  // visitor chose a file
      console.log("[uploadHelper] Uploading " + field.value[0].name + "- Please wait.");
      field.startUpload()
        .then( (uploadedFile) => {
          console.log("[uploadHelper] Upload successful. File is available here:");
          console.log(uploadedFile.url);
		  console.log('[uploadHelper] Setting field value', dbField, uploadedFile.url)
		  dataset.setFieldValue(dbField, uploadedFile.url)
        } )
        .catch( (uploadError) => {
          console.log("[uploadHelper] File upload error: " + uploadError.errorCode);
          console.log(uploadError.errorDescription);
        } );
  }
  else {    // site visitor clicked button but didn't choose a file
    console.log("[uploadHelper] Please choose a file to upload.")
  }
}

Similiar Collections