admin管理员组

文章数量:1327924

I have a form created in a Google Apps spreadsheet and I am trying to find out some of the forms parameter data in my script.

In the following code I don't understand why I am getting an 'Invalid argument' error at the line

var myForm = FormApp.openByUrl(formURL);

even though the log shows what I think is a valid formURL string.

function myFunction() {
  var ss  = SpreadsheetApp.getActive();
  var formURL = ss.getGetFormURL();
  Logger.log('Spreadsheet\'s formURL: %s', formURL);

  var myForm = FormApp.openByUrl(formURL);  // Google script shows the ERROR here
  Logger.log('Form PublishedURL: %s', myForm.getPublishedUrl());

}

I have a form created in a Google Apps spreadsheet and I am trying to find out some of the forms parameter data in my script.

In the following code I don't understand why I am getting an 'Invalid argument' error at the line

var myForm = FormApp.openByUrl(formURL);

even though the log shows what I think is a valid formURL string.

function myFunction() {
  var ss  = SpreadsheetApp.getActive();
  var formURL = ss.getGetFormURL();
  Logger.log('Spreadsheet\'s formURL: %s', formURL);

  var myForm = FormApp.openByUrl(formURL);  // Google script shows the ERROR here
  Logger.log('Form PublishedURL: %s', myForm.getPublishedUrl());

}
Share Improve this question edited Jun 26, 2020 at 20:45 Wicket 38.5k9 gold badges78 silver badges193 bronze badges asked May 24, 2013 at 22:45 user2419137user2419137 611 silver badge3 bronze badges 2
  • report issues/bugs here code.google./p/google-apps-script-issues/issues/list – eddyparkinson Commented May 27, 2013 at 13:49
  • 1 Documentation says openByUrl() "Throws an exception if the URL is invalid or the user does not have permission to open the form." Did you check that permissions were set appropriately? – Mogsdad Commented May 27, 2013 at 15:56
Add a ment  | 

2 Answers 2

Reset to default 4

Try opening the form using its ID rather than the URL. You can find the ID of the form from its URL.

 var myForm = FormApp.openById(id)

openById and openByUrl only works with the NEW forms service. So if form was created with old service, it won't work. See:

http://code.google./p/google-apps-script-issues/issues/detail?id=2866

本文标签: javascriptWhy do I get an 39Invalid argument url39 error in the openByUrl(formURL) callStack Overflow