所以我要做的是每次提交表单时都会运行一些代码来检查某个单元格是否正常。如果它很好我想要它创建那个选择,但如果它不好,那么我希望它不创建选择。这是我当前的代码,但我无法在.setChoices
中放置if语句plt.imshow( np_image.astype(np.uint8) )
所以我想要的就是这样的
var ss = SpreadsheetApp.openById("1QARjdbtFpERRkP7Mw7Ud56plOygMzQawjQbXsbf9Hgw");
var mh1 = ss.getRange ("Helicopter Status!C4");
var mh2 = ss.getRange ("Helicopter Status!C5");
var hellcat1 = ss.getRange ("Helicopter Status!C6");
var hellcat2 = ss.getRange ("Helicopter Status!C7");
var form = FormApp.getActiveForm();
var item = form.addListItem();
var items = form.getItems();
var deleteold = items[2];
form.deleteItem(deleteold);
Utilities.sleep(200);
item.setTitle('Helicopters')
.setRequired(true)
.setChoices([
item.createChoice('MH-9 #1'),
item.createChoice('MH-9 #2'),
item.createChoice('Hellcat #1'),
item.createChoice('Hellcat #2')
])
var items = form.getItems();
var movenew = items[5];
form.moveItem(movenew, 2)
答案 0 :(得分:0)
也许你不需要在选择中执行你的if语句。进入setChoices,你传递一个数组[];为什么不在setChoices之外构建那个数组 - 将它分配给变量然后传入变量。
var choices = []
if(mh1 === 'Fine'){
Logger.log('Hit if')
choices.push(item.createChoice('MH-9 #1'));
}
choices.push(item.createChoice('MH-9 #2'))
choices.push(item.createChoice('Hellcat #1'))
choices.push(item.createChoice('Hellcat #2'))
item.setTitle('Helicopters').setRequired(true).setChoices(choices)