Google Apps script makes life easier

Was stuck with a problem today, my HTC phone synced all contacts wrongly between facebook and google(I really don’t know how), the result was that all my contacts were weird and mixed. Someone else’s FB profile picture corresponds to someone else’s name and email id now. I was thinking about what can be done. Within the first 10 seconds, doing it manually was ruled out(:P). I didn’t want to spend the rest of my life doing that.

Now, I thought I should ask my best friend for some help, so I fired up Google and tried looking but no help :'(. I remembered reading about Google API sometime for Apps, and a quick google search got me here Google apps script

I had a smile on my face when I realized what a boon it was. Next was to think about how to fix this, it was easier than expected, the link between my google and facebook contacts is created using an entry in the contact notes. So I knew what to do now 🙂

I went to the Contacts API and it was butter smooth to use it. The documentation is amazing. So this is what I did:

Step 1:

Load all contacts


The function returns an array of type Contact[]

Step 2:

Process these contacts one by one


  for ( var i = 0; i < contacts.length ; ++i ) 

In each iteration, we have an object of type Contact[], can be accessed by contacts[i]

Step 3:

For each contact, set the notes to blank

  contacts[i].setNotes( '' );



Also, you can log what is going on very easily using


To fire up the logger, use Ctrl+Enter or go to View->Logs

As easy as that. Google, you saved my day 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s