Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

javascript - Error when using dictionaries for variable with Google App Script

I have a spreadsheet with information that I would like to use to create a calendar invite. Everything is running smoothly except for the inviting guest part. Currently when the calendar invite is created, my invitees email will show up as "commissioner1 = 'email'" or "commissioner 2 = 'email'" instead of just the email. The problem is that commissioner1, commissioner2, etc. becomes the key but I don't know how to get about this. Any suggestions?

   
  // get spreadsheet 
  var ss = SpreadsheetApp.getActiveSpreadsheet(); 
  var sheet = ss.getSheetByName('SHEET NAME'); 
   
  // get the data from Google Sheet. The three numbers mean: current row, start with column one, end with column 6.
  var data = sheet.getRange(sheet.getLastRow(),1,1,10).getValues(); 
  
  //  create variables 
  var eventLoca = 'https://notredame.zoom.us/j/7813564440 Meeting ID: 781 356 4440';
  var startTime = data[0][0]; 
  var endTime  = data[0][1];
  var commissioner1 = data[0][7];
  var commissioner2 = data[0][8];
  var commissioner3 = data[0][9];
  var commissioner_dict = {}
  if ("" == commissioner2){
    commissioner_dict['key'] = commissioner1
  }
  else if("" == commissioner3){
    commissioner_dict['key'] = [commissioner1,commissioner2]
  }
  else{
    commissioner_dict['key'] = [commissioner1,commissioner2,commissioner3]
  };
  // get calendar 
  var masterCal = CalendarApp.getCalendarById('CALENDAR_ID'); 
   
  // add to calendar 
  masterCal.createEvent('Check In Meeting', 
                        new Date(startTime), 
                        new Date(endTime), 
                        {location:eventLoca,description:'Meeting to check in before next semester',guests:commissioner_dict['key'],sendInvites:true});}

My columns in the spreadsheet are: startsTime,endTime,date,time,commissionerName1,commissionerName2,commissionerName3,commissionerEmail1,commissionerEmail2,commissionerEmail3


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...