Google Workspace 加载项错误:类型错误:无法读取未定义的属性"stringInputs"



我试图创建一个谷歌工作空间插件,但在试图访问我的第一张卡的输入值时不断得到这个错误:

TypeError: Cannot read property 'stringInputs' of undefined

我不确定我做错了什么。这是我第一次尝试GWAO,我不是程序员,所以我认为这是一些愚蠢的东西。

应用程序应该做什么的背景:

获取文本输入并将其应用于公司电子邮件地址。获取选中的下拉输入并获取关联的日历ID。获取日期输入,并将电子邮件添加到所选日历上日期范围内的所有事件中。

下面是代码-一些细节被替换为占位符:

function cardHomepage() {
let cardHeader1 = CardService.newCardHeader()
.setTitle('Welcome to the training scheduler!')
.setSubtitle('Select what you'd like to do')
.setImageUrl(
'<IMAGE_URL>'
)
.setImageStyle(CardService.ImageStyle.CIRCLE);
let cardSection1ButtonList1Button1Action1 = CardService.newAction()
.setFunctionName('addAllCard');
let cardSection1ButtonList1Button1 = CardService.newTextButton()
.setText('Add someone to all trainings')
.setTextButtonStyle(CardService.TextButtonStyle.TEXT)
.setOnClickAction(cardSection1ButtonList1Button1Action1);
let cardSection1ButtonList1Button2Action1 = CardService.newAction()
.setFunctionName('TODO');
let cardSection1ButtonList1Button2 = CardService.newTextButton()
.setText('Add someone to one training')
.setTextButtonStyle(CardService.TextButtonStyle.TEXT)
.setOnClickAction(cardSection1ButtonList1Button2Action1);
let cardSection1ButtonList1Button3Action1 = CardService.newAction()
.setFunctionName('TODO');
let cardSection1ButtonList1Button3 = CardService.newTextButton()
.setText('Remove someone from all trainings')
.setTextButtonStyle(CardService.TextButtonStyle.TEXT)
.setOnClickAction(cardSection1ButtonList1Button3Action1);
let cardSection1ButtonList1Button4Action1 = CardService.newAction()
.setFunctionName('TODO');
let cardSection1ButtonList1Button4 = CardService.newTextButton()
.setText('Remove someone from one training')
.setTextButtonStyle(CardService.TextButtonStyle.TEXT)
.setOnClickAction(cardSection1ButtonList1Button4Action1);
let cardSection1ButtonList1 = CardService.newButtonSet()
.addButton(cardSection1ButtonList1Button1)
.addButton(cardSection1ButtonList1Button2)
.addButton(cardSection1ButtonList1Button3)
.addButton(cardSection1ButtonList1Button4);
let cardSection1 = CardService.newCardSection()
.addWidget(cardSection1ButtonList1);
let card = CardService.newCardBuilder()
.setHeader(cardHeader1)
.addSection(cardSection1)
.build();
return card;
}

// Add to all card
function addAllCard() {
let cardHeader1 = CardService.newCardHeader()
.setTitle('Add to all')
.setSubtitle('Add someone to all trainings')
.setImageUrl(
'<IMAGE_URL>'
)
.setImageStyle(CardService.ImageStyle.SQUARE);
let cardSection1TextInput1 = CardService.newTextInput()
.setFieldName('text')
.setTitle('LDAP')
.setMultiline(false);
let cardSection1SelectionInput1 = CardService.newSelectionInput()
.setFieldName('trainCal')
.setTitle('Training calendar to use')
.setType(CardService.SelectionInputType.DROPDOWN)
.addItem('CS Trainings', '<CALENDAR_ID>', false)
.addItem('PL Trainings', '<CALENDAR_ID>', false)
.addItem('Test Cal', '<CALENDAR_ID>', false);
let cardSection1Divider1 = CardService.newDivider();
let cardSection1DecoratedText1 = CardService.newDecoratedText()
.setTopLabel('Date range')
.setText(
'Select the date range for which to add the person to trainings.')
.setWrapText(true);
let cardSection1DatePicker1 = CardService.newDatePicker()
.setFieldName('startDate')
.setTitle('Range start date');
let cardSection1DatePicker2 = CardService.newDatePicker()
.setFieldName('endDate')
.setTitle('Range end date');
let cardSection1ButtonList1Button1Action1 = CardService.newAction()
.setFunctionName('addToAllCS');
let cardSection1ButtonList1Button1 = CardService.newTextButton()
.setText('Schedule')
.setBackgroundColor('#1967d2ff')
.setDisabled(false)
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setOnClickAction(cardSection1ButtonList1Button1Action1);
let cardSection1ButtonList1 = CardService.newButtonSet()
.addButton(cardSection1ButtonList1Button1)
let cardSection1 = CardService.newCardSection()
.addWidget(cardSection1TextInput1)
.addWidget(cardSection1SelectionInput1)
.addWidget(cardSection1Divider1)
.addWidget(cardSection1DecoratedText1)
.addWidget(cardSection1DatePicker1)
.addWidget(cardSection1DatePicker2)
.addWidget(cardSection1ButtonList1);
let card = CardService.newCardBuilder()
.setHeader(cardHeader1)
.addSection(cardSection1)
.build();
return card;
}

// Adds a user to all events on the chosen calendar within a specific timeframe.
function addToAllCS(e){ 
let ldap = e.commonEventObject.formInputs.text[""].stringInputs.value[0];
let calendar = e.commonEventObject.formInputs.trainCal[""].stringInputs.value;
let startD = e.commonEventObject.formInputs.startD[""].dateInput;
let endD = e.commonEventObject.formInputs.endD[""].dateInput;
let guestEmail = ldap + "@<COMPANY_DOMAIN>"; // Email address of the person to add.
let cal = CalendarApp.getCalendarById(calendar); // Calendar to use.
let calEvents = cal.getEvents(new Date(startD), new Date(endD)); // Gets all of the events within the timeframe.
console.log(calEvents.length); // Checks how many events it found.
for (var i = 0; i < calEvents.length; i++) { // Loops through all events and adds the person to each of them.
let event = calEvents[i];
event.addGuest(guestEmail);
}
}

与一位发现["]不再需要的同事交谈。下面的方法是:

let ldap = e.commonEventObject.formInputs.text.stringInputs.value[0];
let calendar = e.commonEventObject.formInputs.trainCal.stringInputs.value;
let startD = e.commonEventObject.formInputs.startD.dateInput;
let endD = e.commonEventObject.formInputs.endD.dateInput;

相关内容

  • 没有找到相关文章

最新更新