1
votes

Background:

I am pushing the contacts list from Google Spreadsheet to Google Contacts, either creating or updating the current Google Contacts. I have got the entire script working except for this tiny problem. As my contact list consists of people from all over the world, I need to account for the different name structure. So there are times when an individual may not have a "givenName".

Issue:

The method to create a contact in Google Contacts via Google App Script is as createContact(givenName, familyName, email). My current script is bounded to a Google Spreadsheet (if it matters).

Is there any way to create a contact without a givenName? or setGivenName(givenName) as a blank?

1

1 Answers

3
votes

I hope you know that givenName stands for the First Name of any person and the familyName is significantly the Last Name of any person. So technically, a person has to have a First Name.

But in your case, if you wish to create a contact without any givenName, you can achieve this by putting a whitespace in the cell corresponding to the contact that does not have a givenName. That will work.

Here it is for your reference :

var contact = ContactsApp.createContact(' ', 'Gandhi', '[email protected]');