根据电子表格自动填写Google表单字段 [英] Autofill a Google Form Fields Based on a Spreadsheet

查看:113
本文介绍了根据电子表格自动填写Google表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/ li>

  • 日期

  • 资产标签



  • 然后说我有一个包含所有学生ID号码和姓名的Google电子表格。



    有没有办法自动填充当输入学号码时,基于电子表格的表格?

    解决方案

    是的,您可以使用表单ID创建预填充响应,而不是预填充字段显示在URL

     函数formPrefill(formId){
    var form = FormApp.openById(formId);
    尝试{
    var items = form.getItems();
    var formResponse = form.createResponse();
    //预填充SessionId
    var formItem =在这里设置
    var response = formItem.createResponse(sessionId);
    formResponse.withItemResponse(response);

    // --------其他字段-------------
    formItem = items [4] .asMultipleChoiceItem();
    response = formItem.createResponse('您的字段名称');
    formResponse.withItemResponse(response);
    $ b $ catch(e){在这里捕获一个错误}


    }

    请查看 https://开发者.google.com / apps-script / reference / forms / form#createresponse


    Say I have a Google Form with the fields:

    • ID
    • First Name
    • Last Name
    • Date
    • Asset Tag

    Then say I have a google spreadsheet that has all of the students id numbers and names.

    Is there a way to autofill the form based on the spreadsheet when the student id number is entered?

    解决方案

    Yes you can create a pre filled response with the forms ID, not that the pre filled fields are showed in the URL

    Function formPrefill(formId){
        var form = FormApp.openById(formId);
        try{
        var items = form.getItems();
        var formResponse = form.createResponse();
        // Prefill SessionId
        var formItem = "SOMETHING HERE"
        var response = formItem.createResponse(sessionId);
        formResponse.withItemResponse(response);
    
        //--------ANOTHER FIELD-------------
        formItem = items[4].asMultipleChoiceItem();
        response = formItem.createResponse('YOUR FIELD NAME');
        formResponse.withItemResponse(response);
    
        }catch(e){catch an error here}
    
    
    }
    

    check https://developers.google.com/apps-script/reference/forms/form#createresponse

    这篇关于根据电子表格自动填写Google表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆