App Script Card Service - 如何知道点击了哪个网格项?

App Script Card Service - How to know what grid item was clicked?

看看这段代码,我怎么知道点击了哪个项目?

根据所选项目,我将调用 api 服务,你能帮我吗?

CardService.newGrid()
  .setTitle("title")                                  
  .setBorderStyle(CardService.newBorderStyle().setType(CardService.BorderType.STROKE))
  .setOnClickAction(
          CardService.newAction()
             .setFunctionName("testGrid"))
  .setNumColumns(2)
  .addItem(CardService.newGridItem()
                   .setTitle("X1"))
  .addItem(CardService.newGridItem()
                   .setTitle("X2"))
  .addItem(CardService.newGridItem()
                   .setTitle("Y3"))
  .addItem(CardService.newGridItem()
                   .setTitle("Y4"))

function testGrid(e){
 console.log("How do I know which item is?");
}
      

找到解决方案,这是我的错误:

CardService.newGrid()
  .setTitle("title")                                  
  .setBorderStyle(CardService.newBorderStyle().setType(CardService.BorderType.STROKE))
  .setOnClickAction(
          CardService.newAction()
             .setFunctionName("testGrid"))
  .setNumColumns(2)
  .addItem(CardService.newGridItem()
                   .setTitle("X1")
                   .setIdentifier("idX1"))
  .addItem(CardService.newGridItem()
                   .setTitle("X2")
                   .setIdentifier("idX2"))
  .addItem(CardService.newGridItem()
                   .setTitle("Y3")
                   .setIdentifier("idY3"))
  .addItem(CardService.newGridItem()
                   .setTitle("Y4")
                   .setIdentifier("idY4"))

function testGrid(e){
  if(e.parameters.grid_item_identifier == "idY4"){
    console.log("Y4 clicked!!!!");
  }
   
}