Skip to main content

Delete Question

Deletes a question from a Google Form at a specified position.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Form Id - The unique identifier of the Google Form from which the question should be deleted.
  • Index - The position (1-based) of the question to be deleted from the form.

How It Works

The Delete Question node removes a question from an existing Google Form at the specified position. When executed, the node:

  1. Validates the required inputs (Form Id and Index)
  2. Retrieves the Google Form using the provided Form Id
  3. Validates the index position (must be greater than 0)
  4. Constructs a request to delete the item at the specified index position
  5. Uses the Google Forms API to remove the question from the form
  6. The form is updated with the question removed

Requirements

  • A valid Google Forms form ID
  • Appropriate permissions to modify the form
  • Valid index position (must be greater than 0 and refer to an existing question)

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid Form Id
  • Empty or invalid Index
  • Invalid Index value (0 or negative)
  • Google Forms API errors during question deletion
  • Insufficient permissions to modify the form
  • Index refers to a position that doesn't exist in the form

Usage Notes

  • The Index is 1-based, meaning position 1 is the first question in the form
  • Deleting a question shifts all subsequent questions to lower positions
  • This operation cannot be undone through the API
  • Make sure the index refers to an existing question in the form
  • Historical responses to the deleted question are preserved but the question itself is removed from future submissions
  • Consider using caution with this node, especially in production environments
  • You must use OpenForm or CreateForm node before this node to establish a connection
  • Use GetForm before deletion to verify the correct index of the question to delete

Example Use Cases

Remove Outdated Question

Form Id: {{form_id}}
Index: 5

Use Case: Remove a question that is no longer relevant (e.g., a seasonal question that has expired)

Clean Up Test Questions

Form Id: {{form_id}}
Index: 1

Flow:
1. Open Form (development form)
2. Delete Question (remove test question at index 1)
3. Repeat as needed for cleanup

Use Case: Remove test questions before deploying a form to production

Dynamic Question Removal

Form Id: {{form_id}}

Flow:
1. Get Form to retrieve structure
2. Identify question to remove by title or content
3. Calculate index of question
4. Delete Question at calculated index

Use Case: Programmatically remove specific questions based on form analysis

Conditional Question Cleanup

Form Id: {{form_id}}

Flow:
1. Get Form
2. For each question in form:
- If question contains "TEMP" or "TEST":
- Delete Question at index

Use Case: Automatically clean up temporary or test questions from forms

Tips for Effective Use

  • Verify Before Deleting: Always use GetForm first to inspect the form structure and confirm the correct index
  • Backup Responses: If you need response data for the deleted question, use GetResponses to save it before deletion
  • Index Shifting: Remember that deleting a question shifts all subsequent questions down by one position
  • Batch Deletions: When deleting multiple questions, delete from highest index to lowest to avoid index shifting issues
  • Test Environment: Test deletion operations on a copy of the form before applying to production forms
  • Alternative Approach: Consider creating a new form instead of modifying an existing one if major restructuring is needed

Index Shifting Behavior

When you delete a question, all subsequent questions move up to fill the gap:

Before Deletion:
Index 1: Question A
Index 2: Question B
Index 3: Question C (← delete this)
Index 4: Question D
Index 5: Question E

After Deleting Index 3:
Index 1: Question A
Index 2: Question B
Index 3: Question D (was index 4)
Index 4: Question E (was index 5)

Common Errors and Solutions

Error: "Form not found. Please use Open Form node first"

Cause: The form_id doesn't exist in the current session or OpenForm/CreateForm wasn't called first. Solution: Use OpenForm or CreateForm node before DeleteQuestion to establish a connection to the form.

Error: "Form ID cannot be empty"

Cause: The Form Id input is empty or not set. Solution: Pass the form_id from CreateForm or OpenForm node output to this input.

Error: "Index cannot be empty"

Cause: The Index input is empty. Solution: Provide a valid index number (1 or greater) indicating which question to delete.

Error: "Index must be at least 1"

Cause: Index is set to 0 or negative number. Solution: Use 1-based indexing. First question is at index 1, second at index 2, etc.

Error: "Invalid index format"

Cause: The Index contains non-numeric characters. Solution: Ensure Index is a valid number (e.g., "1", "2", "3"). If using a variable, verify it contains a numeric string.

Error: "Failed to delete question"

Cause: API error during deletion, often because the index doesn't exist. Solution:

  • Use GetForm to check how many questions exist
  • Verify the index is within the valid range (1 to number of questions)
  • Check that you have edit permissions for the form
  • Ensure the index refers to a question item, not a section or other form element

Error: "Insufficient permissions to modify the form"

Cause: Credentials don't have edit permission for the form. Solution:

  • For Service Accounts: Ensure the form is shared with "Editor" permission
  • For OAuth2: Verify the authenticated user has edit access
  • Check that credentials include the Forms Body scope

Integration Examples

Safe Question Deletion with Validation

1. Open Form
- URL: "https://docs.google.com/forms/d/abc123/edit"
- Output: form_id

2. Get Form
- Form Id: {{form_id}}
- Output: form

3. Validate:
- Total questions: {{form.items.length}}
- Question at index 3: {{form.items[2].title}}

4. If form.items.length >= 3:
- Delete Question
- Form Id: {{form_id}}
- Index: 3
- Log: "Deleted question: {{form.items[2].title}}"
- Else:
- Log: "Cannot delete - index out of range"

Bulk Question Cleanup

Delete multiple questions from highest to lowest index:

1. Open Form
- URL: {{form_url}}
- Output: form_id

2. Set Variable: questions_to_delete = [5, 3, 1] (sorted descending)

3. For Each index in questions_to_delete:
- Delete Question
- Form Id: {{form_id}}
- Index: {{index}}
- Log: "Deleted question at index {{index}}"

Note: Delete from highest index first to avoid shifting issues

Question Replacement

Replace a question by deleting and adding a new one:

1. Open Form
- URL: {{form_url}}
- Output: form_id

2. Delete Question
- Form Id: {{form_id}}
- Index: 3
- (Removes old question at position 3)

3. Add Closed-Ended Question
- Form Id: {{form_id}}
- Question Title: "New improved question"
- Answers: ["Option A", "Option B", "Option C"]
- Index: 3
- Type: Radio

This replaces the question at position 3 with a new one

Conditional Question Removal Based on Responses

Remove questions with no responses:

1. Open Form
- URL: {{form_url}}
- Output: form_id

2. Get Form
- Form Id: {{form_id}}
- Output: form

3. Get Responses
- Form Id: {{form_id}}
- Output: responses

4. For Each item in form.items:
- Set Variable: has_responses = false
- For Each response in responses:
- If response.answers contains item.questionId:
- has_responses = true
- Break

- If NOT has_responses:
- Calculate index from form.items position
- Delete Question
- Form Id: {{form_id}}
- Index: {{calculated_index}}
- Log: "Deleted unused question: {{item.title}}"

Form Reorganization

Remove deprecated sections from a multi-section form:

1. Open Form
- URL: {{form_url}}
- Output: form_id

2. Get Form
- Form Id: {{form_id}}
- Output: form

3. Find deprecated section:
- For Each item in form.items:
- If item.title contains "[DEPRECATED]":
- Add item.index to deletion_list

4. Sort deletion_list descending

5. For Each index in deletion_list:
- Delete Question
- Form Id: {{form_id}}
- Index: {{index}}

6. Log: "Removed {{deletion_list.length}} deprecated questions"

A/B Test Cleanup

Remove questions from losing A/B test variant:

1. Analyze A/B test results
- Winner: Variant A
- Loser: Variant B

2. Open Form
- URL: {{form_url}}
- Output: form_id

3. Get Form
- Form Id: {{form_id}}
- Output: form

4. For Each item in form.items:
- If item.title contains "[Variant B]":
- Delete Question
- Form Id: {{form_id}}
- Index: {{item current index}}

5. Keep only winning variant questions

Archive Before Delete

Safely archive question data before deletion:

1. Open Form
- URL: {{form_url}}
- Output: form_id

2. Get Form
- Form Id: {{form_id}}
- Output: form

3. Get question to delete:
- question_data = form.items[index_to_delete - 1]

4. Save to database:
- Table: archived_questions
- Data: {
form_id: {{form_id}},
question_title: {{question_data.title}},
question_type: {{question_data type}},
deleted_at: {{current_timestamp}},
question_json: {{JSON.stringify(question_data)}}
}

5. Delete Question
- Form Id: {{form_id}}
- Index: {{index_to_delete}}

6. Log: "Question archived and deleted successfully"

This ensures you have a backup of the question structure