Adds everyone in your signup spreadsheet to Google Contacts, matching on email so nobody is entered twice.
Uses
Google Contacts
Google Sheets
Add your signup sheet to Google Contacts
signupSheetUrl to blank.Set signupSheetUrl to blank.signupTabName to blank.Set signupTabName to blank.signupSheetUrl. Save it as signupSheet.Read the rows of signupSheetUrl. Save it as signupSheet.signupRows to signupSheet.rows.Set signupRows to signupSheet.rows.signupRowCount to 0.Set signupRowCount to 0.rowCountErrorIf a step below fails, save the error as rowCountErrorTry
signupRows and save it as signupRowCount.Count the items in signupRows and save it as signupRowCount.On error
signupRowCount to 0.Change signupRowCount to 0.signupRowCount is 0If signupRowCount is 0Yes
No
No steps
addressBook.List contacts. Save it as addressBook.knownContacts to addressBook.contacts.Set knownContacts to addressBook.contacts.knownContactCount to 0.Set knownContactCount to 0.contactCountErrorIf a step below fails, save the error as contactCountErrorTry
knownContacts and save it as knownContactCount.Count the items in knownContacts and save it as knownContactCount.On error
knownContactCount to 0.Change knownContactCount to 0.knownContactCount is 0If knownContactCount is 0Yes
knownContacts.Start an empty list and save it as knownContacts.No
No steps
knownEmails.Start an empty list and save it as knownEmails.knownContact in knownContacts:For each knownContact in knownContacts:knownEmail to blank.Set knownEmail to blank.contactEmailErrorIf a step below fails, save the error as contactEmailErrorTry
knownContact.email lowercase and save it as knownEmail.Make knownContact.email lowercase and save it as knownEmail.On error
knownEmail to blank.Change knownEmail to blank.knownEmail is emptyIf knownEmail is emptyYes
knownEmail to (this contact has no email address).Change knownEmail to (this contact has no email address).No
No steps
knownEmail to the end of knownEmails and save it as knownEmails.Add knownEmail to the end of knownEmails and save it as knownEmails.addedPeople.Start an empty list and save it as addedPeople.updatedPeople.Start an empty list and save it as updatedPeople.needsAttention.Start an empty list and save it as needsAttention.skippedRows.Start an empty list and save it as skippedRows.alreadyCurrentCount to 0.Set alreadyCurrentCount to 0.signupRow in signupRows:For each signupRow in signupRows:firstName to blank.Set firstName to blank.lastName to blank.Set lastName to blank.signupEmail to blank.Set signupEmail to blank.signupPhone to blank.Set signupPhone to blank.firstNameReadErrorIf a step below fails, save the error as firstNameReadErrorTry
signupRow["First Name"] and save it as firstName.Trim signupRow["First Name"] and save it as firstName.On error
firstName to blank.Change firstName to blank.lastNameReadErrorIf a step below fails, save the error as lastNameReadErrorTry
signupRow["Last Name"] and save it as lastName.Trim signupRow["Last Name"] and save it as lastName.On error
lastName to blank.Change lastName to blank.signupEmailReadErrorIf a step below fails, save the error as signupEmailReadErrorTry
signupRow.Email and save it as signupEmail.Trim signupRow.Email and save it as signupEmail.On error
signupEmail to blank.Change signupEmail to blank.signupPhoneReadErrorIf a step below fails, save the error as signupPhoneReadErrorTry
signupRow.Phone and save it as signupPhone.Trim signupRow.Phone and save it as signupPhone.On error
signupPhone to blank.Change signupPhone to blank.firstName lastName and save it as personName.Trim firstName lastName and save it as personName.rowLabel to personName.Set rowLabel to personName.rowLabel is emptyIf rowLabel is emptyYes
rowLabel to signupEmail.Change rowLabel to signupEmail.No
No steps
rowLabel is emptyIf rowLabel is emptyYes
rowLabel to A row with no name and no email address.Change rowLabel to A row with no name and no email address.No
No steps
firstName is emptyIf firstName is emptyYes
rowLabel - the 'First Name' column is empty, and a contact needs a first name. to the end of skippedRows and save it as skippedRows.Add rowLabel - the 'First Name' column is empty, and a contact needs a first name. to the end of skippedRows and save it as skippedRows.No
No steps
signupEmail is a valid email addressIf not signupEmail is a valid email addressYes
rowLabel - the 'Email' column is empty or is not an email address. Without one there is no way to tell whether they are already in your contacts, so this row was left alone. to the end of skippedRows and save it as skippedRows.Add rowLabel - the 'Email' column is empty or is not an email address. Without one there is no way to tell whether they are already in your contacts, so this row was left alone. to the end of skippedRows and save it as skippedRows.No
No steps
signupEmail lowercase and save it as matchKey.Make signupEmail lowercase and save it as matchKey.matchKey in knownEmails and save it as matchIndex.Find the position of matchKey in knownEmails and save it as matchIndex.matchIndex is less than 0If matchIndex is less than 0Yes
createdResource to blank.Set createdResource to blank.createErrorIf a step below fails, save the error as createErrorTry
firstName. Save it as createResult.Create contact firstName. Save it as createResult.createResult.resource_name and save it as createdResource.Trim createResult.resource_name and save it as createdResource.On error
rowLabel - could not be added to Google Contacts: createError as text to the end of skippedRows and save it as skippedRows.Add rowLabel - could not be added to Google Contacts: createError as text to the end of skippedRows and save it as skippedRows.createdResource isn't emptyIf createdResource isn't emptyYes
rowLabel to the end of addedPeople and save it as addedPeople.Add rowLabel to the end of addedPeople and save it as addedPeople.knownContacts and save it as knownContacts.Add a record of resourceName, fullName, email, and phone to the end of knownContacts and save it as knownContacts.matchKey to the end of knownEmails and save it as knownEmails.Add matchKey to the end of knownEmails and save it as knownEmails.No
No steps
No
existingContact to knownContacts[@matchIndex].Set existingContact to knownContacts[@matchIndex].existingResource to blank.Set existingResource to blank.resourceErrorIf a step below fails, save the error as resourceErrorTry
existingContact.resourceName and save it as existingResource.Trim existingContact.resourceName and save it as existingResource.On error
existingResource to blank.Change existingResource to blank.existingResource is emptyIf existingResource is emptyYes
rowLabel - matches a contact that came back without an ID, so it could not be updated. to the end of skippedRows and save it as skippedRows.Add rowLabel - matches a contact that came back without an ID, so it could not be updated. to the end of skippedRows and save it as skippedRows.No
existingName to blank.Set existingName to blank.nameErrorIf a step below fails, save the error as nameErrorTry
existingContact.fullName and save it as existingName.Trim existingContact.fullName and save it as existingName.On error
existingName to blank.Change existingName to blank.existingPhone to blank.Set existingPhone to blank.phoneErrorIf a step below fails, save the error as phoneErrorTry
existingContact.phone and save it as existingPhone.Trim existingContact.phone and save it as existingPhone.On error
existingPhone to blank.Change existingPhone to blank.firstNameToAdd to blank.Set firstNameToAdd to blank.lastNameToAdd to blank.Set lastNameToAdd to blank.existingName is emptyIf existingName is emptyYes
firstNameToAdd to firstName.Change firstNameToAdd to firstName.lastNameToAdd to lastName.Change lastNameToAdd to lastName.No
No steps
phoneToAdd to blank.Set phoneToAdd to blank.signupPhone isn't emptyIf signupPhone isn't emptyYes
existingPhone is emptyIf existingPhone is emptyYes
phoneToAdd to signupPhone.Change phoneToAdd to signupPhone.Else if @existingPhone is not @signupPhone
rowLabel - your sheet says signupPhone but their contact card says existingPhone. The contact was left as it is; change it by hand if the sheet is right. to the end of needsAttention and save it as needsAttention.Add rowLabel - your sheet says signupPhone but their contact card says existingPhone. The contact was left as it is; change it by hand if the sheet is right. to the end of needsAttention and save it as needsAttention.Otherwise
No steps
No
No steps
firstNameToAdd isn't empty or phoneToAdd isn't emptyIf firstNameToAdd isn't empty or phoneToAdd isn't emptyYes
updateErrorIf a step below fails, save the error as updateErrorTry
existingResource.Update contact existingResource.rowLabel to the end of updatedPeople and save it as updatedPeople.Add rowLabel to the end of updatedPeople and save it as updatedPeople.On error
rowLabel - is already in your contacts but could not be updated: updateError as text to the end of skippedRows and save it as skippedRows.Add rowLabel - is already in your contacts but could not be updated: updateError as text to the end of skippedRows and save it as skippedRows.No
alreadyCurrentCount.Add 1 to alreadyCurrentCount.runSummary to Signup sheet checked against Google Contacts.Set runSummary to Signup sheet checked against Google Contacts.
Added: the length of addedPeople as text
Updated: the length of updatedPeople as text
Already up to date: alreadyCurrentCount as text
Needs a look: the length of needsAttention as text
Skipped: the length of skippedRows as text.addedPeople isn't emptyIf addedPeople isn't emptyYes
runSummary to runSummaryChange runSummary to runSummary
Added to your contacts:
addedPeople joined by a new line.No
No steps
updatedPeople isn't emptyIf updatedPeople isn't emptyYes
runSummary to runSummaryChange runSummary to runSummary
Filled in on contacts you already had:
updatedPeople joined by a new line.No
No steps
needsAttention isn't emptyIf needsAttention isn't emptyYes
runSummary to runSummaryChange runSummary to runSummary
Worth a look:
needsAttention joined by a new line.No
No steps
skippedRows isn't emptyIf skippedRows isn't emptyYes
runSummary to runSummaryChange runSummary to runSummary
Skipped:
skippedRows joined by a new line.No
No steps
runSummary.Show in the output: runSummary.