callback - Passing an Array with Objects to another function in GAS -
just give little background on question: creating form in google app script using ui services , storing specific calendar events in dataarray. event object stored in array. want pass array submit function can't figure out how go because :
- i can't add callback element (because isn't widget)
- i can't store event object in widget (i.e. listbox, etc) , add widget callback element.
here brief sample of trying do:
var cal= calendarapp.getdefaultcalendar(); var event= cal.getevents(new date("june 16, 2013 pst"), new date("july 22, 2013 pst")); var specific = new array; for( var j=0; j<event.length;j++){ specific.push(event[j]); //this stores events in specific variable //i want send variable (w/ data) function on submit
i appreciate suggestions can lend me.
thanks!
as complement answer gave in comments : "you store id , while read events again using same start/end time can check if event correspond saved id in loop... if match found right id sure it's right event"
here piece of code use modify/update/delete calendar events using id reference. code used delete specific events selected spreadsheet, code modify events same, @ least uses same id checking.
... var cal = calendarapp.openbyname(calname); if (cal) { var events = cal.getevents(new date(date_deb), new date(date_fin),{max: 4000}); // stocke tt ds une variable array var sel= sh.getrange(6,1,sh.getlastrow()-5, 10).getvalues();// read data in ss for(e=0;e<events.length;++e){ var delflag = false; var id = events[e].getid(); for(n=0;n<sel.length;++n){ if ((sel[n][8] == "x"||sel[n][8] == "x")&&sel[n][9]==id){ // id here stored in spreadsheet in column j , use 'x' marker select event should deleted delflag = true; sh.getrange(n+6,9,1,2).setbackgroundcolor('#ff5500'); spreadsheetapp.flush(); logger.log('flag '+ e); break; } } if(delflag){ try{ var todelete = events[e].deleteevent(); ++todel; delflag = false; logger.log('event deleted : '+sel[n][1]); }catch(err){logger.log('event serie deleted occurence')} } } } var msg = todel + " événement(s) effacé(s) dans l'agenda '"+calname+"'"; ss.toast("effacement terminé", msg, 3); ...
Comments
Post a Comment