user2419137
user2419137

Reputation: 61

Why do I get an 'Invalid argument: url' error in the openByUrl(formURL) call?

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());

}

Upvotes: 6

Views: 8079

Answers (2)

Norman Cousineau
Norman Cousineau

Reputation: 337

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.com/p/google-apps-script-issues/issues/detail?id=2866

Upvotes: 1

ECWyne
ECWyne

Reputation: 433

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)

Upvotes: 4

Related Questions