Google 스프레드 시트의 문서 바인딩 된 Google Appscript에서 스프레드 시트를 Google 캘린더 약속으로 바꾸는 스크립트를 만들었습니다. 이 기능은 나에게 잘 작동하지만 내 동료에게는 그렇지 않습니다. 우리는 캘린더를 수정하고 공유 권한을 변경할 수있는 권한을 가지고 있지만 직장 동료는 calendar.google.com에서 캘린더에 약속을 만들 수 있음을 증명했습니다.Google Apps Script에서 시트에서 캘린더 일정을 금지 하시겠습니까?
그는 스크립트를 실행할 때 그는 다음과 같은 오류 메시지를 가져옵니다 :
{"message":"Forbidden","name":"GoogleJsonResponseException","fileName":"SCHEDULER","lineNumber":204,"stack":"\tat SCHEDULER:204 (createAppointments)\n"}
라인 (204)이 명령에 해당을 :
Calendar.Events.insert(event, CAL, {sendNotifications: true, supportsAttachments:true});
그는에 편집 권한이있는 경우 달력, 왜 금지 된거야? Google Apps Script의 캘린더 서비스에 문제가 있습니까? 게다가 CAL 변수를 개인적으로 만든 캘린더로 변경하여 동일한 권한으로 그와 공유했습니다. 그는 그 달력을 잘 편집 할 수 있습니다.
여기
function createAppointments() {
var CAL = '[email protected].com';
for(/*each row in spreadsheet*/)
{
if(/*needs appointment*/)
{
var object = {/*...STUFF...*/};
var coworker = '[email protected]';
var timeArgs = {start: /*UTC Formatted time*/, end: /*UTC Formatted time*/}
if(/*All the data checks out*/{
var summary = 'Name of appointment'
var notes = 'Stuff to put in the body of the calendar appointment';
var location = '123 Happy Trail, Monterrey, TX 12345'
//BUILD GOOGLE CALENDAR OBJECT
var event = {
"summary": summary,
"description": notes,
"start": {
"dateTime": timeArgs.start,
"timeZone": TZ
},
"end": {
"dateTime": timeArgs.end,
"timeZone": TZ
},
"guestsCanInviteOthers": true,
"reminders": {
"useDefault": true
},
"location": location
//,"attendees": []
};
event.attendees = [{[email protected], displayName: 'coworker name'}];
//CREATE CALENDAR IN GOOGLE CALENDAR OF CONST CAL
Calendar.Events.insert(event, CAL, {sendNotifications: true, supportsAttachments:true});
} else{/*Tell user to fix data*/}
}
}
매우 감사 기능에 대한 psuedocode입니다!
업데이트 2017년 12월 29일는 :
제이슨 Allshorn 크레이지 이반에 따라 응용 프로그램을 조정 시도했습니다. 지금까지 도와 줘서 고마워! 흥미롭게도 Advanced Calendar Service와 CalendarApp를 사용하여 동일한 응답을 보았습니다.
<!DOCTYPE html><html><head><link rel="shortcut icon" href="//ssl.gstatic.com/docs/script/images/favicon.ico"><title>Error</title><style type="text/css">body {background-color: #fff; margin: 0; padding: 0;}.errorMessage {font-family: Arial,sans-serif; font-size: 12pt; font-weight: bold; line-height: 150%; padding-top: 25px;}</style></head><body style="margin:20px"><div><img alt="Google Apps Script" src="//ssl.gstatic.com/docs/script/images/logo.png"></div><div style="text-align:center;font-family:monospace;margin:50px auto 0;max-width:600px">Object does not allow properties to be added or changed.</div></body></html>
또는 HTML 편집기를 통해 그 구문 분석 후 :
것을조차 무엇을 의미 하는가 아래와 같이
오류는 무엇입니까? 고급 서비스가 활성화되어 있고 스크립트를 다른 사람이 실행할 수 있습니다. 어떤 아이디어?
나는 CalendarApp/Advanced Calendar 이벤트 생성 명령을 실행하려고 시도한 후에 오류가 다시 발생하는지 테스트 한 후 확인했습니다.
function convertURItoObject(url){
url = url.replace(/\+/g,' ')
url = decodeURIComponent(url)
var parts = url.split("&");
var paramsObj = {};
parts.forEach(function(item){
var keyAndValue = item.split("=");
paramsObj[keyAndValue[0]] = keyAndValue[1]
})
return paramsObj; // here's your object
}
function doPost(e) {
var data = e.postData.contents;
data = convertURItoObject(data);
var CAL = data.cal;
var event = JSON.parse(data.event);
var key = data.key;
var start = new Date(event.start.dateTime);
if(ACCEPTEDPROJECTS.indexOf(key) > -1)
{
try{
var calendar = CalendarApp.getCalendarById(CAL);
calendar.createEvent(event.summary, new Date(event.start.dateTime), new Date(event.end.dateTime), {description: event.description, location: event.location, guests: event.guests, sendInvites: true});}
/*try {Calendar.Events.insert(event, CAL, {sendNotifications: true, supportsAttachments:true});} Same error when I use this command*/
catch(fail){return ContentService.createTextOutput(JSON.stringify(fail));}
e.postData.result = 'pass';
return ContentService.createTextOutput(JSON.stringify(e));
}
else {
return ContentService.createTextOutput('Execution not authorized from this source. See CONFIG of target project for details.');
}
}