从Google Apps脚本中预先填写Google表单 [英] pre-fill google form from google apps script

查看:119
本文介绍了从Google Apps脚本中预先填写Google表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个学生登记表,其中有一个学生证,这是必填字段.我有一个Google Apps脚本功能,该功能可以告诉该学生是否已注册任何课程.是否可以通过调用google apps脚本功能是"或否"来自动填写注册的实地课程.

I have a student registration form, there's student id which is a required field. I have a google apps script function which tells if this student is registered for any class or not. Is there a way to auto-fill the field course registered via calling the google apps script function yes or no.

推荐答案

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

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}


}

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

这篇关于从Google Apps脚本中预先填写Google表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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