簡體   English   中英

當單元格被編輯為谷歌表格應用程序腳本中的某些文本時,如何觸發 function?

[英]How to trigger function when cell is edited to certain text in google sheet app script?

我是初學者,對應用腳本了解不多,我很期待學習應用腳本。 當單元格等於“TRUE”並且不想使用按鈕觸發此 function 時,我正在嘗試運行此 function

The main issue is I'm trying to share the form using &rm=minimal URL but the button seems didn't work, https://docs.google.com/spreadsheets/d/17hyNNI2mEiWjtUpTf1G1JJvtp3UcGJmzMv4n205nAKo/edit? &rm=最小#gid=0

其次,我嘗試使用 HTML 提交按鈕,但仍然沒有工作。 然后現在需要在單元格等於時嘗試觸發此 function。 我嘗試學習 onEdit function 但在這里有點損失......這是我的 function

function SubmitData() {
  
  var ss          = SpreadsheetApp.getActiveSpreadsheet();
  var formSS      = ss.getSheetByName("Form"); 
  var datasheet   = SpreadsheetApp.openById("156va3bF91wJVYu7y7JQ_NrFEoO1GferSkOdP5P8Wveg").getSheetByName("Data Entered");

  var values      = [[formSS.getRange("E4").getValue(),
                      formSS.getRange("C4").getValue(),
                      formSS.getRange("C50").getValue(),
                      formSS.getRange("C51").getValue()]];
  
  datasheet.getRange(datasheet.getLastRow()+1, 1, 1, 4).setValues(values);
      
  formSS.getRange('E4').clearContent();
  formSS.getRange('C4').clearContent(); 
  formSS.getRange('C50:C51').clearContent();

}  

示例:我想添加這個

function onEdit(e){

//don't know how to point the cell here

  if('B52' == 'TRUE'){  //if cell equal to text
  SubmitData() //run the function and needed to set the value to 'FALSE' again

 }
}

希望有人可以在這里幫助我...

您想在單元格更改時檢查值是否為“TRUE”(無需按下另一個按鈕)?

onEdit() https://developers.google.com/apps-script/guides/triggers

可能是您正在尋找的東西。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM