Google apps script 获取指向“a”的URL链接;第「;只有

Google apps script 获取指向“a”的URL链接;第「;只有,google-apps-script,google-forms,Google Apps Script,Google Forms,假设我是一名招聘经理,我需要在20个不同的日期与20名不同的候选人进行面试,如果他们能在上述日期参加面试,我需要一份“是”或“否”的确认书。我只想在表格中显示指定给面试者的日期,但我需要在表格中隐藏其他日期(对于其他面试者),以便它们显示在“回答”表中。他们感到“特别”也很重要,所以我需要在预先填充的文本字段中用他们的名字来称呼他们(这个文本字段将在响应表中填充)。重要的是要让候选人彼此隐藏起来,这样他们才不会气馁,所以制作一个预先填充的“下拉”菜单供他们选择不是一个选项 理想情况下,这些受访者

假设我是一名招聘经理,我需要在20个不同的日期与20名不同的候选人进行面试,如果他们能在上述日期参加面试,我需要一份“是”或“否”的确认书。我只想在表格中显示指定给面试者的日期,但我需要在表格中隐藏其他日期(对于其他面试者),以便它们显示在“回答”表中。他们感到“特别”也很重要,所以我需要在预先填充的文本字段中用他们的名字来称呼他们(这个文本字段将在响应表中填充)。重要的是要让候选人彼此隐藏起来,这样他们才不会气馁,所以制作一个预先填充的“下拉”菜单供他们选择不是一个选项

理想情况下,这些受访者在打开表单时只能看到两个字段:

  • 全名(预填充的文本字段)
  • 没有指定日期(多选:“是”或“否”)

重述:

  • 1个谷歌表单(2个表单字段-其余隐藏)
  • 20名受访者(预填充文本字段)
  • 20个指定日期(多选:“是”或“否”)
  • 1谷歌“回应”表(21栏)
我尝试过…

  • 基于预填充的“多项选择”答案的预填充URL链接(运气不佳)
  • 谷歌表单“隐藏字段”研究(不走运)
  • 发送指向“表单部分”的自定义链接的研究(可能?)

  • 有人知道实现这一目标的最佳方法吗

    提前谢谢


    谷歌表单

       ┌────────────────────────┐
       │  NAME (pre-populated)  │
       └────────────────────────┘
    
        Will you be attending on <custom-date>?
    
            ⦿ YES
            ⦾ NO
            ⦾ MAYBE
    
       ╔════════╗
       ║ SUBMIT ║
       ╚════════╝
    

    您可以为每个受访者创建具有唯一URL参数的个性化链接,并使用应用程序脚本doGet(e)功能获取这些参数并为个性化网页提供服务

    简而言之,可以像下面这样创建个性化链接,向webApp发送get请求 ?name=A2&date=2017年1月2日 并使用以下命令获取URL参数:

    function doGet(e){
        var param = e.queryString //Will get name=A2&date=1/2/2017
        //or
        var param = e.parameter  //Will get {"name": "A2", "date": "1/2/2017"}
    }
    

    您可以使用simple=连接公式创建个性化链接,如“Sheet2”中的示例所示。您可以将此个性化链接发送给每个受访者,当他们访问网页时,您可以在URL参数上为他们提供个性化网页,如下所示:

    function doGet(e) {
    
      var param = e.queryString
      var parameters = param.split("&")
      // This just checks only 2 parameters are present else gives a invalid link
      if (param != null && parameters.length == 2){
        param = e.parameter
        var name = param.name
        var date = param.date
      var html = HtmlService.createHtmlOutputFromFile("Invite")
      var htmlTemplate = html.asTemplate().getRawContent()
      // use the replace function to input the name and date on the page 
      // You also replace the hidden input values at the same time
      htmlTemplate = htmlTemplate.replace(/customName#/gi, name )
      htmlTemplate = htmlTemplate.replace(/customDate#/gi, date)
      html = HtmlService.createHtmlOutput(htmlTemplate).asTemplate().evaluate()
      }else {
        var html = HtmlService.createHtmlOutput("<b> Invalid Link <b>")
      }
      return html
    
    }
    
    函数doGet(e){
    var param=e.queryString
    变量参数=参数拆分(&)
    //这只是检查只有2个参数存在,否则给出无效链接
    if(param!=null&¶meters.length==2){
    param=e.parameter
    var name=param.name
    变量日期=参数日期
    var html=HtmlService.createHtmlOutFromFile(“邀请”)
    var htmlTemplate=html.asTemplate().getRawContent()
    //使用replace函数在页面上输入名称和日期
    //您还可以同时替换隐藏的输入值
    htmlTemplate=htmlTemplate.replace(/customName#/gi,name)
    htmlTemplate=htmlTemplate.replace(/customDate#/gi,date)
    html=HtmlService.createHtmlOutput(htmlTemplate.asTemplate().evaluate())
    }否则{
    var html=HtmlService.createHtmlOutput(“无效链接”)
    }
    返回html
    }
    
    Html代码:

    <!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
       <div id ="div_form">
        <form id="RSVPform" onSubmit = "return false">
        <h1> customName# </h1> <br>
        <input type = "hidden" id = "name" value = 'customName#' >
        Will you be attending on customDate# <br>
        <input type = "hidden" id = "date" value = 'customDate#' >
        <input type = "radio" name = "RSVP" value = "Yes" checked>Yes <br>
        <input type = "radio" name = "RSVP" value = "No">No <br>
        <input type = "radio" name = "RSVP" value = "Maybe">Maybe <br>
        <button type = "button" onClick ="sendRSVP()">Submit</button>
        </form>
        </div>
        <div id="accept"></div>
        <script>
    
        function sendRSVP(){
        var resp = []
         resp[0] = document.getElementById("name").value
         resp[1] = document.getElementById("date").value
         resp[2] = document.querySelector('input[name="RSVP"]:checked').value;
        google.script.run.withSuccessHandler(closeForm).enterRSVP(resp)
        }
    
        function closeForm(foundIndex){
        var subResp
        if(foundIndex){
          subResp = "Thank You for your response"
    
        } else {
          subResp = "Oops! Cannot find the meeting event"
        }
    
        document.getElementById("div_form").style.display = "none"
        document.getElementById("accept").innerHTML = subResp
        }
    
        </script>
      </body>
    </html>
    
    
    customName#
    您将在customDate参加会议吗 是

    也许
    提交 函数sendRSVP(){ var resp=[] resp[0]=document.getElementById(“名称”).value resp[1]=document.getElementById(“日期”).value resp[2]=document.querySelector('input[name=“RSVP”]:checked')。值; google.script.run.withSuccessHandler(closeForm.EnterSVP(resp) } 函数closeForm(foundIndex){ var subResp 如果(索引){ subResp=“感谢您的回复” }否则{ subResp=“Oops!找不到会议事件” } document.getElementById(“div_form”).style.display=“无” document.getElementById(“接受”).innerHTML=subResp }
    最后,此代码将检查并输入对电子表格中相应行和列的响应

    function enterRSVP(resp){
     var ss = SpreadsheetApp.openById(id) 
     var sheet = ss.getSheetByName("Sheet1")
     var RSVPdata = sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues()
     //match name
     for (var i=0;i<RSVPdata.length;i++){
       if(resp[0] == RSVPdata[i][0]){
         var setRowIndex = true
         break
       }
     }
      if(setRowIndex)
        var rowIndex = i+1
      else
        return false
      //Match Date
      for (var i= 0; i<RSVPdata[0].length; i++){
        if(resp[1] == RSVPdata[0][i]) {
          var setColIndex = true
          break
        }
      }
       if(setColIndex)
         var colIndex = i+1
       else
         return false
    
       sheet.getRange(rowIndex,colIndex).setValue(resp[2])
       return true
    }
    
    函数输入rsvp(resp){
    var ss=电子表格应用程序.openById(id)
    var sheet=ss.getSheetByName(“Sheet1”)
    var RSVPdata=sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues()
    //匹配名称
    
    对于(var i=0;i,您可以为每个受访者创建具有唯一URL参数的个性化链接,并使用应用程序脚本doGet(e)函数获取这些参数并为个性化网页提供服务

    简而言之,可以像下面这样创建个性化链接,向webApp发送get请求 ?name=A2&date=2017年1月2日 并使用以下命令获取URL参数:

    function doGet(e){
        var param = e.queryString //Will get name=A2&date=1/2/2017
        //or
        var param = e.parameter  //Will get {"name": "A2", "date": "1/2/2017"}
    }
    

    您可以使用simple=连接公式创建个性化链接,如“Sheet2”中的本例所示。您可以将此个性化链接发送给每个受访者,当他们访问网页时,您可以在URL参数上为他们提供个性化网页,如下所示:

    function doGet(e) {
    
      var param = e.queryString
      var parameters = param.split("&")
      // This just checks only 2 parameters are present else gives a invalid link
      if (param != null && parameters.length == 2){
        param = e.parameter
        var name = param.name
        var date = param.date
      var html = HtmlService.createHtmlOutputFromFile("Invite")
      var htmlTemplate = html.asTemplate().getRawContent()
      // use the replace function to input the name and date on the page 
      // You also replace the hidden input values at the same time
      htmlTemplate = htmlTemplate.replace(/customName#/gi, name )
      htmlTemplate = htmlTemplate.replace(/customDate#/gi, date)
      html = HtmlService.createHtmlOutput(htmlTemplate).asTemplate().evaluate()
      }else {
        var html = HtmlService.createHtmlOutput("<b> Invalid Link <b>")
      }
      return html
    
    }
    
    函数doGet(e){
    var param=e.queryString
    变量参数=参数拆分(&)
    //这只是检查只有2个参数存在,否则给出无效链接
    if(param!=null&¶meters.length==2){
    param=e.parameter
    var name=param.name
    变量日期=参数日期
    var html=HtmlService.createHtmlOutFromFile(“邀请”)
    var htmlTemplate=html.asTemplate().getRawContent()
    //使用replace函数在页面上输入名称和日期
    //您还可以同时替换隐藏的输入值
    htmlTemplate=htmlTemplate.replace(/customName#/gi,name)
    htmlTemplate=htmlTemplate.replace(/customDate#/gi,date)
    html=HtmlService.createHtmlOutput(htmlTemplate.asTemplate().evaluate())
    }否则{
    var html=HtmlService.createHtmlOutput(“无效链接”)
    }
    返回html
    }
    
    Html代码:

    <!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
       <div id ="div_form">
        <form id="RSVPform" onSubmit = "return false">
        <h1> customName# </h1> <br>
        <input type = "hidden" id = "name" value = 'customName#' >
        Will you be attending on customDate# <br>
        <input type = "hidden" id = "date" value = 'customDate#' >
        <input type = "radio" name = "RSVP" value = "Yes" checked>Yes <br>
        <input type = "radio" name = "RSVP" value = "No">No <br>
        <input type = "radio" name = "RSVP" value = "Maybe">Maybe <br>
        <button type = "button" onClick ="sendRSVP()">Submit</button>
        </form>
        </div>
        <div id="accept"></div>
        <script>
    
        function sendRSVP(){
        var resp = []
         resp[0] = document.getElementById("name").value
         resp[1] = document.getElementById("date").value
         resp[2] = document.querySelector('input[name="RSVP"]:checked').value;
        google.script.run.withSuccessHandler(closeForm).enterRSVP(resp)
        }
    
        function closeForm(foundIndex){
        var subResp
        if(foundIndex){
          subResp = "Thank You for your response"
    
        } else {
          subResp = "Oops! Cannot find the meeting event"
        }
    
        document.getElementById("div_form").style.display = "none"
        document.getElementById("accept").innerHTML = subResp
        }
    
        </script>
      </body>
    </html>
    
    
    customName#
    您将在customDate参加会议吗 是

    也许
    提交 函数sendRSVP(){ var-re