Javascript (Google Scripts) value from a function is not returning -


i think simple 1 solve, stuck working simple issue out.

i have called createevent function create google calendar event. part of function google calendar event id eventid , want return it.

for reason dont quite understand, eventid value not return.

  var eventid;    createevent(calendarid,title,startdt,enddt,desc,eventid);    logger.log('id after func = '+eventid);     sheet.getrange(lr,eventidholder,1,1).setvalue(eventid); };  function createevent(calendarid,title,startdt,enddt,desc,eventid) {   var cal = calendarapp.getcalendarbyid(calendarid);   var start = new date(startdt);   var end = new date(enddt); //manually set location, can modified dynamic modifying code if need   //var loc = sheet.getrange(lr,destid,1,1).getvalue();   var loc = "some location" //set options, in case using description , location, not need guests or sendinvites   var event = cal.createevent(title, start, end, {       description : desc,       location : loc   });    logger.log('event = '+event);     var eventid = event.getid();     logger.log('id generated = '+eventid);     return eventid;  }; 

even if i'm not javascript expert, i'd find more logical write (assigning value directly eventid variable) :

  ...   var eventid = createevent(calendarid,title,startdt,enddt,desc);   logger.log('id after func = '+eventid);   sheet.getrange(lr,eventidholder,1,1).setvalue(eventid); }  function createevent(calendarid,title,startdt,enddt,desc) {   var cal = calendarapp.getcalendarbyid(calendarid);   var start = new date(startdt);   var end = new date(enddt);   //manually set location, can modified dynamic modifying code if need   //var loc = sheet.getrange(lr,destid,1,1).getvalue();   var loc = "some location"   //set options, in case using description , location, not need guests or sendinvites   var event = cal.createevent(title, start, end, {     description : desc,     location : loc   });   logger.log('event = '+event);   var eventid = event.getid();   logger.log('id generated = '+eventid);   return eventid;  } 

note : agree mogsdad comment below semicolumns not being mandatory... anyway, code working without ;-)


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -