Opening an URL from a form submission is not possible in Apps Script because during form submission, the form editor is not open.
Based on Class Ui:
A script can only interact with the UI for the current instance of an open editor, and only if the script is container-bound to the editor.
One workaround I could suggest is to send an email to the respondent with the url link.
Sample Form:
- Each Yes or No multiple choice question is set to required.
- Collect email addresses is enabled under Forms Settings
- Custom confirmation message was set under Forms Settings "Please check your email for the reference link"
Forms Script Editor:
Sample Code:
function onSubmitForm(e) {
var response = e.response;
//Get item responses
var items =response.getItemResponses();
//Get respondent's email
var email = response.getRespondentEmail();
var url;
var A = [];
//Convert responses Yes/No to 1/0
for(var i = 0; i<items.length; i++){
A.push(items[i].getResponse()=="Yes"?1:0);
}
Logger.log(A);
Logger.log(!A[0] * !A[1] * !A[4] * A[5] * (!A[2] + A[3]));
//Check if logical expression was satisfied A'B'E'F ( C' + D )
if(!A[0] * !A[1] * !A[4] * A[5] * (!A[2] + A[3])){
url = "https://www.youtube.com/?hl=en&gl=PH";
}else{
url = "https://google.com";
}
//Send Email with the link
var subject = "Test Email";
var body = "Please refer to this link: "+url;
MailApp.sendEmail(email,subject,body);
}
Sample Trigger Configuration:
Output:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…