Я думал, что это будет просто. У меня есть календарное событие 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 = "lb@emailindustries.com"; // 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
Форум по Javascript
1738732887
Anonymous
Я думал, что это будет просто. У меня есть календарное событие Google и форма Google. Я пытаюсь отредактировать скрипт приложения, чтобы, когда пользователь подал свой адрес электронной почты, единственное поле в форме, он добавит их в событие календаря Google, указанное идентификатором. < /P>
[b] Календарное событие [/b]: https://calendar.google.com/calendar/event?action=template p>
[b] Google Форма отправки просмотра [/b]: https://docs.google.com/forms/d/e/1faipqlsfnu2sk8g4r84xlyjasyjcmkt32r2t3xpgoozvwdddlact-rna/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[i].getItem().getType() === FormApp.ItemType.TEXT){
email = itemResponses[i].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 = "lb@emailindustries.com"; // 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>
Я попробовал новый старт, потому что В первый раз, когда я не добавил прицел календаря до развертывания, и мне нужно было запустить повторную авторизацию проекта после добавления прицела календаря. Вместо просто по электронной почте, но это все еще выбрасывает ту же ошибку.
Что я здесь делаю?
Подробнее здесь: [url]https://stackoverflow.com/questions/79413713/google-form-app-script-to-add-email-to-calendar-event-returns-referenceerror-em[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия