javascript - Modify Existing Google Calendar Events -
below script created modify existing calendar events. goal change description have change register button registration closed. script works in add guests, not update description new description when max number of registrants has been exceeded. did not include part of script details calproperties.
function modifyevents() { var ss = spreadsheetapp.getactive(); var sheet = ss.getsheetbyname("events"); var sheetr = ss.getsheetbyname("registration"); var headerrows = 1; var datarange = sheet.getdatarange(); var data = datarange.getvalues(); (var = 1; in data; ++i) { if (i << headerrows) { var row = data[i]; var room = row[5]; var description = row[6]; var agegroup = row[7]; var registration = row[8]; var max = row[10]; var calname = row[14]; var eventid = row[15]; var registrants = row[17]; var calendarname = sheet.getrange(headerrows + i, 15).getvalue(); var calendarid = calproperties.getproperty(calendarname); var cal = calendarapp.getcalendarbyid(calendarid); var id = sheet.getrange(headerrows + i, 16).getvalue(); var event = cal.geteventseriesbyid(id); var email = sheetr.getrange(headerrows + i, 8).getvalue(); row[10] = sheet.getrange(headerrows + i, 11).getvalue(); row[17] = sheet.getrange(headerrows + i, 18).getvalue(); if (registration === 'y' && registrants >> max) {//7.1 line 25 var description1 = (description + '\n' + '\n' + room + '\n' + '\nevent type: ' + calname + '\n' + '\nage group: ' + agegroup) var descriptionhtml = '\n <div id="registration_button" ><a style="text-align:right;color:white!important;text-decoration:bold;background-color:rgb(209,72,54);background-image:-webkit-linear-gradient(top,rgb(221,75,57),rgb(209,72,54));color:#ffffff;border:1px solid rgba(0,0,0,0);border-radius:2px;display:inline-block;font-size:12px;font-weight:bold;height:27px;line-height:27px;padding:0px 20px 0px 20px;text-align:center;text-transform:uppercase;white-space:nowrap;text-decoration:none;color:white" target="_blank">registration closed</a>'; var descriptionregistration = (description1 + '\n' + '\n' + descriptionhtml); event.setdescription(descriptionregistration); } } } }
replace (i << headerrows)
with (i < headerrows)
and replace registration === 'y' && registrants >> max
with registration === 'y' && registrants > max
there difference between >
, >=
greater , greater or equal , :
>>
<<
bitwise operands left , right did not want
<<
left shift shifts in binary representation b (< 32) bits left, shifting in zeroes right.
>>
sign-propagating right shift shifts in binary representation b (< 32) bits right, discarding bits shifted off.
what want >
greater "the greater operator returns true if left operand greater right operand."
or
<
less "the less operator returns true if left operand less right operand."
Comments
Post a Comment