Why Am I Getting an Invalid Question ID XX Check Your Merge Code Error?

If you are using merge codes to reference information collected in your survey, from time to time you may see the following error:

[Invalid question ID: "X". Check your merge code.]

Invalid Merge Code Example

This error could pop up in the following places:

Have you come across this error? Not sure why? This happens from time to time, typically in copied surveys or long-running surveys. There are a number of places where this can happen; basically wherever merge codes can be used, which is just about everywhere!

To brush up on merge codes check out our Merge Code Tutorial for more info.

What Causes the Error?

The error happens when a merge code references a Question ID that no longer exists. In our above example, our survey is referencing question ID 2 via a merge code that was added to a Text Instructions Element. However, we deleted question ID 2 from our survey and now the merge code can't reference that question anymore.

You can see how this might happen more often in copied surveys. Say you copy a survey that a colleague built. You add a few questions, delete a few questions, and send out the share link forgetting there are merge codes being used throughout the survey or within a send email action. Boom! Error messages all over the place!

How Do I Fix It?

SurveyGizmo will not automatically update or fix invalid merge codes. They are invalid because the questions that they are referencing are no longer in your survey. As such, you will need to locate these invalid merge codes and either remove or update them.

Using our above example (where we see the invalid merge code in a Text Element), let's see how we can fix this issue:

  1. Assuming you received the invalid merge code error, head to the survey's Build tab and edit the question, element, or action that contains the error. In our example, we will edit the Text Element that generated the error.
    Edit Element with Invalid Merge Code
  2. In our example, the error was generated by Question ID 2 (since that question was deleted from our survey). As such, we will delete this merge code from our text element.
    Remove Merge CodeIn some cases, this is all you need to do. Perhaps in your case the question was deleted because it was no longer needed. If this is the case, you can delete the merge code, save the element, and be finished.
  3. In our example, Question ID 2 was deleted, but it was replaced with a new version of the question. As a result we will need to add a merge code for the new question. To do so, we will use the Merge Code helper tool to add the merge code for the new question.
    1. Let's click the Merge Codes button to bring up the merge code helper.
    2. Next, we will locate the new question on the Pages & Questions tab and will click on that question.
    3. Finally, we will use the Insert link associated with the Question Answer to insert the merge code that we want to use.
      Add Updated Merge Code
  4. We now have the correct merge code inserted into our Text Element and will no longer see the invalid merge code error.
    Updated Merge Code

Check out our Merge Code Tutorial to learn how to use the Merge Code Helper to insert the proper merge codes. You can even take advantage of our Find & Replace tool to search for merge codes in larger surveys.

Identify Additional Invalid Merge Codes

If you are concerned that you have additional invalid merge codes, the best way to identify these is to manually test your survey. This process should help you see any invalid merge codes in questions and text elements. Make sure to toggle the setting to Fire Actions to make sure that any actions that might be using merge codes don't get missed.

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In