0

I'm creating a simple vehicle monitoring system using Google Sheets. I have drawn a shape to be used as a button, and I've assigned a script to it.

Here's the script I'm trying to run:

function newlto() {
var form 
=FormApp.openById('1kJLfksSYgOv6Q0UGjdnklg2E5J5R03mIUHoefIvuZ28');
}

The script is supposed to open my Google Form, however, the script runs no problem but it does not open the form, after the "Finished running script" notification at the top-center, nothing happens.

Kelvs
  • 97
  • 2
  • 14
  • 1
    May I clarify something? What exactly do you mean when you say "open my Google Form"? Do you open the form in a browser, or open the form in the editor, or edit the form with a script, or something other meaning? – Tedinoz Jul 04 '19 at 04:34
  • @Tedinoz, sorry for the incomplete information. What I meant was to open the Google Form on a new tab in my browser so that the user can input data on it. Thank you! – Kelvs Jul 04 '19 at 05:04

2 Answers2

1

You are trying to open a Google Form from a script. Google Apps Script will not automatically open web pages, and a Google Form is a web page - so you can't write a script to open a form.

You may find it easier to create a simple hyperlink to the Google Form.

The steps to do this (assuming that you have access to the form editor):


Send Form
Send Form


  1. click "Send",
  2. at the top of the screen where it says "Send via", click the middle icon for the link,
  3. click the link ( or a variation here is to click the "Shorten URL" box to get, well, a shorter URL),
  4. click "Copy" (to put a copy of the link into memory,
  5. switch to your spreadsheet and paste the link into a cell.

This automatically creates a hyperlink. To access the URL, hover you have to hover the hyperlink, and then click the popup box that appears.

You would probably benefit from reading these topics which cover issues sim You should read:

Rubén
  • 34,714
  • 9
  • 70
  • 166
Tedinoz
  • 5,911
  • 3
  • 25
  • 35
0

I guess you want to open the form using a button, using something like window.open(); the problem is that Apps Script is server scripting and this method cannot be called from a server script but with a client script. If you try to use it it will prompts an error message indicating that window is not defined.

when you use FormApp.openById(); you are opening the form on the server to work on the Form by using the script, is like doing the same steps manually on the browser but with coding on the server. You can find more information on the Apps Script - Forms website.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Mario R.
  • 659
  • 5
  • 11
  • Please read: https://stackoverflow.com/help/behavior (don't include salutions, greatings, slogans, inspirational quotes,... on questions / answers) – Rubén Jul 05 '19 at 01:47