Report: Rule of Item IDs for Questions of Google Forms

Gists

This is a report related to the rule of item IDs for questions of Google Forms.

When the questions are created using the method of batchUpdate with Google Forms API, the created questions have the item IDs when the item IDs are not given in the request body. ( https://developers.google.com/forms/api/reference/rest/v1/forms#item ) For example, when you want to create a question and update the created question in one API call, it is required to include the custom item ID in the request body. But, it seems that in the current stage, the information of the item ID has never been published. So, in this report, I would like to consider the rule of item IDs of questions for Google Forms API.

When I had tested Google Forms API at the beta version, unless I’m mistaken, I had understood that the rule of item ID might be required to be the values from 00000000 to 7fffffff as the hexadecimal value. By the way, for example, it seems that 0 is used as 00000000 which is 8 digits.

When this is reflected in a sample script, it becomes as follows.

Sample script:

const res = Math.floor(Math.random() * parseInt("7FFFFFFF", 16))
  .toString(16)
  .padStart(8, "0");
console.log(res);
  • In this sample script, the values of 00000000 to 7fffffff are randomly returned.

Reference

 Share!