Google Forms Script Error – Parameters (null) Don’t Match Method Signature

google sheetsgoogle-apps-scriptgoogle-forms

when I am running the script below I am getting the message – Exception: The parameters (null) don't match the method signature for FormApp.Form.getItemById. (line 38, file "Code")
it has been working right so far. I do not know what happened but it started to show this error:

var ssID = "1Z7uUBnzS5zKnxGswKKNAgn2XbRunqIzQZMATDl7skoE";
var formID = "1LxORhL2WgU6teJ11ax7_HsFxhbpXbjtFXiuPH5qfEfA";

var wsData = SpreadsheetApp.openById(ssID).getSheetByName("Questions#1");
var form = FormApp.openById(formID);

function updateDropdown(id,values) {
  var item = form.getItemById(id);
  item.asListItem().setChoiceValues(values);
}

Please help to find the problem and fix it!

Best Answer

The code in the question only include a function that require two parameters. The error mentioned in the question will be thrown if you call that function directly from custom menu, button (image with this function assigned), an installable trigger, from google.script.run or the Apps Script API.

The solution is to call the function from another function that pass the required parameters.