-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Problem
Currently, Google Apps Script and Google Forms API do not provide a way to retrieve validation rules for checkbox items in Google Forms.
Current Behavior
When using FormApp.openById() and iterating through form items, checkbox items created with item.asCheckboxItem() do not expose any methods to access validation rules such as:
- Minimum number of selections required
- Maximum number of selections allowed
- Custom validation messages
Expected Behavior
There should be methods available to retrieve validation rules for checkbox items, similar to how other form item types expose their validation settings.
Use Case
We need to programmatically read form structures including validation rules to:
- Display proper validation messages in custom form renderers
- Replicate form validation logic in external applications
- Generate form documentation that includes validation requirements
Code Example
function getFormData(formId) {
var form = FormApp.openById(formId);
var items = form.getItems();
items.forEach(function(item) {
if (item.getType() === FormApp.ItemType.CHECKBOX) {
var checkboxItem = item.asCheckboxItem();
// These methods don't exist but would be useful:
// checkboxItem.getValidation()
// checkboxItem.getMinSelections()
// checkboxItem.getMaxSelections()
// checkboxItem.getValidationHelpText()
}
});
}Impact
This limitation prevents developers from creating comprehensive form processing tools and custom form UIs that need to respect the original form's validation rules.
Workaround
Currently, there is no known workaround to retrieve this information programmatically.
Environment
- Google Apps Script
- Google Forms API
- FormApp service