Я думал, что это будет просто. У меня есть календарное событие Google и форма Google. Я пытаюсь отредактировать скрипт приложения, чтобы, когда пользователь подал свой адрес электронной почты, единственное поле в форме, он добавит их в событие календаря Google, указанное идентификатором. < /P>
Календарное событие : https://calendar.google.com/calendar/ev ... n=template p>
Google Форма отправки просмотра : https://docs.google.com/forms/d/e/1faip ... a/viewform
app script : < /p>
/**
* Sends a calendar invite to the email address provided in the form response.
*
* @param {Object} e The form submit event object.
*/
function onFormSubmit(e) {
// Get the form response.
var itemResponses = e.response.getItemResponses();
// Get the email address from the form response. Assumes the *first* email field.
// Better would be to search by question title or ID.
var email = "";
for (var i = 0; i < itemResponses.length; i++){
if (itemResponses.getItem().getType() === FormApp.ItemType.TEXT){
email = itemResponses.getResponse();
Logger.log(email);
break; // Stop after finding the first email field.
}
}
if (!email) {
Logger.log("No email address found in the form response.");
return; // Exit if no email is found.
}
// Get the calendar event.
var calendarId = "[email protected]"; // Your calendar ID
var calendar = CalendarApp.getCalendarById(calendarId);
Logger.log(calendar);
const eventId = "NmRsbDFvbGxmbHZnY2xhcHE3MWE5MWJ1bDEgbGJAZW1haWxpbmR1c3RyaWVzLmNvbQ"
try {
const event = calendar.getEventById(eventId);
event.addGuest(email);
Logger.log("Invite sent to " + email);
if (event) {
event.addGuest(email);
Logger.log(`Invited ${email} to event ${event.getTitle()}`);
return `Successfully invited ${email} to ${event.getTitle()}.`; // Success message
} else {
Logger.log(`Event with ID ${eventId} not found.`);
return `Error: Event not found.`; // Event not found message
}
} catch (error) {
Logger.log(`Error inviting ${email}: ${error}`);
return `Error inviting ${email}: ${error.message}`; // Detailed error message
}
}
< /code>
Я позаботился о том, чтобы у проекта для сценария приложения имеется область применения в Google Calendar V3 API < /p>
Я попробовал новый старт, потому что В первый раз, когда я не добавил прицел календаря до развертывания, и мне нужно было запустить повторную авторизацию проекта после добавления прицела календаря. Вместо просто по электронной почте, но это все еще выбрасывает ту же ошибку.
Что я здесь делаю?
Подробнее здесь: https://stackoverflow.com/questions/794 ... ceerror-em
Скрипт приложения Google Form для добавления электронной почты в календарный событие возвращает ссылки: электронная почт ⇐ Javascript
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение