Issue deleting Google Shared Contact

171 Views Asked by At

I've been able to successfully add a contact via the API but I can't delete contacts that I've created.

https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/shared-contacts

function deletecontact()
{
  SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken    ());
  var contacts = SharedContactsApp.getContactById('5c8b05ab8c9f68c6');
  SharedContactsApp.deleteContact('5c8b05ab8c9f68c6');
 }

I get the following error message:

TypeError: Cannot call method "getElements" of undefined. (line 200, file "Code", project "SharedContactsApp")

How to remove this error?

Additionally...

I've tried to set a Job Title using the code below but get the following error:

ReferenceError:"profile" is not defined. (line 142, file "Code")

function changeJobTitle2() 
{
   SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken    ());
  var contact = SharedContactsApp.getContactById('82f05968956d66f');
  profile.setJobTitle('Google Apps Expert');
}
1

There are 1 best solutions below

0
Jared Gallier On

I figured it out.

function hailmary() 
{
  SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken());
  var contact = SharedContactsApp.getContactById('82f05968956d66f');
  SharedContactsApp.deleteContact(contact)
}