Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Google App Script Create Contact

function test() {
  createContact('Test Contact', '08273488734', '');
}

function doGet( req ) {
  const { action, ...data } = req.parameter;
  switch(action) {
    case "create":
      const { name, phone, email } = data;
      createContact( name, phone, email );
      return response().json({
        sucess: true,
        message: 'Berhasil menyimpan kontak ke Google Contacts'
      });
      break;
    default:
      break;
  }
}

function createContact(name, phone, email) {
  const contact = ContactsApp.createContact(name, '', '');
  contact.setMobilePhone(phone);
  if (email) contact.setPrimaryEmail(email);
  const group = ContactsApp.getContactGroup('System Group: My Contacts');
  group.addContact(contact);
  return contact;
}

function response() {
   return {
      json: function(data) {
         return ContentService
            .createTextOutput(JSON.stringify(data))
            .setMimeType(ContentService.MimeType.JSON);
      }
   }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: clear input field 
Javascript :: vuejs bus.emit 2 times 
Javascript :: this.$moment.tz.guess() not working mozilla 
Javascript :: minus converter 
Javascript :: decrement operator functions 
Javascript :: how to jump one page to another on specific tab elementor 
Javascript :: Angular generate by skipping test files 
Javascript :: exit from jshell 
Javascript :: dynamically define routes separated in different pages for React 
Javascript :: is element displayed js 
Javascript :: Wikibreak enforcer 
Javascript :: redux cannot read properties state) = state.useSelector 
Javascript :: How to handle protected routes in React plus redirect user to original URL being visited 
Javascript :: what is clz32 in javascript 
Javascript :: how to auto update the local data after update / delete while using useSWR hook in React 
Javascript :: repidme 
Javascript :: complite nodejs remove ubuntu 
Javascript :: Return Function As Parameter For Self Invoking Function 
Javascript :: jquery validate min and max value 
Javascript :: createTextRange code example 
Javascript :: synchronous file reading 
Javascript :: jquery for get object in 2nd or 3rd place 
Javascript :: Backbone Model Set Can Set Muliple Values At Once 
Javascript :: find result using type: mongoose.Schema.ObjectId, 
Javascript :: react form validation with logic boolean, string and number 
Javascript :: eva icons js 
Javascript :: javascript convert color string to rgb 
Javascript :: node package manager 
Javascript :: knockout empty an observable array 
Javascript :: click mouseup mousedown 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =