Why does the "Invalid argument: url" error appear in the call to openByUrl (formURL)?

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

In the following code, I do not understand why I get the error "Invalid argument" in the line 'var myForm = FormApp.openByUrl (formURL);' although the log shows what I consider to be a valid formURL string.

function myFunction() { var ss = SpreadsheetApp.getActive(); var formURL = ss.getGetFormURL(); Logger.log('Spreadsheet\ formURL: %s', formURL); var myForm = FormApp.openByUrl(formURL); // Google script shows the ERROR here Logger.log('Form PublishedURL: %s', myForm.getPublishedUrl()); } 
+4
source share
2 answers

Try opening the form using your identifier rather than the URL. The form identifier can be found in the URL.

  var myForm = FormApp.openById(id) 
+3
source

openById and openByUrl work only with the NEW forms service. Therefore, if the form was created with the old service, this will not work. Cm:

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

+1
source

Source: https://habr.com/ru/post/1482660/


All Articles