pre-fill google form from google apps script

谁都会走 提交于 2020-07-19 18:13:33

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/38087152/pre-fill-google-form-from-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!