I think I found a solution to your problem. But I must admit that this was not obvious. In the documentation for the application scripts, you have everything to create a pre-populated URL .
BUT for this you need to have an ItemResponse element, and I did not find an explanation for creating it. The trick is that if you have an item , you can get an ItemResponse from it if you get it as a specific type of " asTextItem () ".
The best way to understand this is to look at the code below:
function getPreFilledItem(){ var form = FormApp.openById("YOUR_FORM_ID"); var items = form.getItems(); var itemOfInterest; for(var i in items){ if(items[i].getTitle()=="YOUR_QUESTION_TITLE"){ itemOfInterest=items[i]; } } Logger.log( form.createResponse(). withItemResponse(itemOfInterest.asTextItem().createResponse("PREFILLED_TEXT")). toPrefilledUrl() ); }
Hope this helps you
Harold
source share