google apps script - EventGuest getName() method not working -
i started coding google apps script.
i tried write simple program pull in events calendar , email guests in these events.
i have run 2 problems:
the getname() method returns guest's email address , not name, though name defined in google contacts. (also, if no name defined, according documentation, return null).
i can't seem use getcalendarsbyname method. getcalendarbyid working correctly, getcalendarsbyname method doesn't return calendar wanted. i've tried getownedcalendarsbyname, doesn't work either.
would appreciate anyone.
update @ 7/1 3.30pm: @serge insas, second problem has been solved. however, first problem remains. here's code:
function myfunction() { var calendar = calendarapp.getcalendarsbyname('test calendar'); logger.log(calendar[0].getname()); var today = new date(); // today's date logger.log(today.tolocalestring()); var enddate = new date(); enddate.setdate(today.getdate() +7); // set nextweek's date 7 days today logger.log(enddate.tolocalestring()); var testevents = calendar[0].getevents(today, enddate); logger.log(testevents[0].gettitle()); var guests = testevents[0].getguestlist(); logger.log(guests[0].getname()); }
here log output:
test calendar july 1, 2012 3:27:58 pm edt july 8, 2012 3:27:58 pm edt test event 1 duytri.nguyen07@gmail.com
the last line email other email address, though has been named in contacts.
the method getcalendarsbyname()
returns array (that's why there 's' on calendars), did take account in code adding [0] behind (assuming have 1 cal name or want first occurrence) ?
it easier if provide code using.
(concerning guestname, same comment : please provide code using.)
edit : code. seems you're right, it looks issue ;-/
since guest must in contact list able name guess use contact service guest name... workaround... i'll try , let know...
this should work - don't know why - hangs without result... maybe give try ?
var testevents = calendar[0].getevents(today, enddate); logger.log(testevents[0].gettitle()); var guests = testevents[0].getguestlist(); var guestmail = guests[0].getemail(); logger.log(guestmail); var contact = contactsapp.getcontact(guestmail); var name = contact.getfullname(); logger.log(guestmail+' '+name);
Comments
Post a Comment