Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 我的if语句没有';我好像什么也不输出_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 我的if语句没有';我好像什么也不输出

Google apps script 我的if语句没有';我好像什么也不输出,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我正在使用if语句,条件是一个单元格的值为TRUE,如果为TRUE,我希望另一个单元格的值为语句中给定的值 我用这个来计算哪些框被选中了。因此,如果选中一个框,它将显示“TRUE”,那么我希望另一个单元格显示该框已选中的操作。e、 g如果采购框打勾,我希望另一个单元格显示“已采购” var submit_type_corrective = submit_sheet.getRange('B6').getValue(); var submit_type_Opportunity = submit_

我正在使用if语句,条件是一个单元格的值为TRUE,如果为TRUE,我希望另一个单元格的值为语句中给定的值

我用这个来计算哪些框被选中了。因此,如果选中一个框,它将显示“TRUE”,那么我希望另一个单元格显示该框已选中的操作。e、 g如果采购框打勾,我希望另一个单元格显示“已采购”

var submit_type_corrective = submit_sheet.getRange('B6').getValue();
  var submit_type_Opportunity = submit_sheet.getRange('B7').getValue();
  var submit_type_Preventative =submit_sheet.getRange('E7').getValue();
  var type_submitted = log_sheet.getRange(lastRow_log+1,3);


  if (submit_type_corrective == 'TRUE'){
    type_submitted.setValue('Corrective');
  }


else if (submit_type_Opportunity == 'TRUE'){type_submitted.setValue('Opportunity')}
           else {type_submitted.setValue('Preventative')
    }
我希望单元格显示更正,但即使选中该框,它也会显示为不带任何内容

返回一个值作为其对应的类型(例如,数字、布尔值、日期或字符串)

Google Sheets中复选框单元格的默认基本类型是布尔值,而不是字符串

尝试更改:

  if (submit_type_corrective == 'TRUE') {

或者干脆

  if (submit_type_corrective) {
同样,您必须更新:

  if (submit_type_Opportunity == 'TRUE') {


提示:您可以通过执行以下操作来检查Google应用程序脚本中的值类型

Logger.log(typeof submit_type_corrective);

这在前面的代码中有定义。这只是另一个工作表的最后一行,似乎适用于所有其他提交的变量。它确实为所有其他变量设置了正确的值。虽然现在已经尝试过了,但它似乎仍然没有改变任何东西。请尝试使用
Logger.log(submit\u type\u corrective)并检查日志中的输出,它返回什么?好的,尝试将
if
语句改为
if(submit\u type\u corrective==true){
。我已经在另一个问题中解释了这是如何工作的,以及如何修复它。如果您想阅读更详细的内容,请查看。
  if (submit_type_Opportunity == true) {
  if (submit_type_Opportunity) {
Logger.log(typeof submit_type_corrective);