Google Forms --> trying to get access to the field collecting emailadresses with script

17 views
Skip to first unread message

Arne Ballegeer

unread,
Sep 1, 2021, 8:33:26 AM9/1/21
to Google Apps Script Community
I'm working on a script that automatically adds data from a spreadsheet to a form. Everything works but I can't access the field that collects mandatory email addresses. They attachment and my script. Anyone have a tip?

THKS!

function invullenFormulier() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('Allen');
const data = sheet.getDataRange().getValues();
data.shift();
//console.log(data);

const formulierURL = ss.getFormUrl();
const formulier = FormApp.openByUrl(formulierURL);
const items = formulier.getItems();




for (let i = 0; i < data.length; i++) {
const formResponse = formulier.createResponse();
//invullen email?????
//How can i access the field emailadress?


//invullen voornaam, this is OK!
let formItem = items[0].asTextItem();
let response = formItem.createResponse(data[i][1]);
formResponse.withItemResponse(response);

//invullen familienaam, this is OK!
formItem = items[1].asTextItem();
response = formItem.createResponse(data[i][0]);
formResponse.withItemResponse(response);

const url = formResponse.toPrefilledUrl();
console.log(url);
}
}
Schermafbeelding 2021-09-01 om 14.24.13.png

Clark Lind

unread,
Sep 1, 2021, 8:43:12 AM9/1/21
to Google Apps Script Community
I don't believe the forms API exposes that. That seems to be a higher level function set outside the normal API for building forms.

Arne Ballegeer

unread,
Sep 1, 2021, 9:57:21 AM9/1/21
to Google Apps Script Community
Grrr... Ok, thks! ;)

Op woensdag 1 september 2021 om 14:43:12 UTC+2 schreef cwl...@gmail.com:
Reply all
Reply to author
Forward
0 new messages