The dreaded Data Merge "There is at least one data placeholder that cannot be found" error
when using Data Merge, so many of us have gotten the "There is at least one data placeholder that cannot be found in the data source. Make sure all the placeholders correspond to the fields in the data source." error and have spent way too much time trying to find the issue.
Can Adobe add a way to highlight what InDesign is objecting to when this message happens?
This morning, I gave up and inserted the text manually. There were only 4 elements on each of my 5 Master pages and I could not find the offending object.
![](https://secure.gravatar.com/avatar/bb0a3517f77226f5c7e2c2bdeeb477d1?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
Michael Han commented
Here you go:
function detectAllUnresolvedPlaceholders() {
if (app.documents.length === 0) {
alert("No document is open. Please open a document and try again.");
return;
}var doc = app.activeDocument;
var unresolvedPlaceholders = [];// Helper function to check if a value is in an array
function arrayContains(arr, value) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] === value) {
return true;
}
}
return false;
}try {
// Ensure there is a data merge source
if (!doc.dataMergeProperties || doc.dataMergeProperties.dataMergeFields.length === 0) {
alert("No data merge fields found in the document.");
return;
}// Collect valid field names into a regular JavaScript array
var mergeFields = doc.dataMergeProperties.dataMergeFields;
var validFieldNames = [];
for (var i = 0; i < mergeFields.length; i++) {
validFieldNames.push(mergeFields[i].fieldName);
}// Iterate through all text frames and search for placeholders
var allTextFrames = doc.textFrames;
for (var j = 0; j < allTextFrames.length; j++) {
var frame = allTextFrames[j];// Check for hidden or overset frames
if (!frame.visible || frame.overflows) {
unresolvedPlaceholders.push(
"Text frame at index " + j + " is hidden or overset."
);
continue;
}// Search for placeholders in the text
var placeholderPattern = /<<([^>>]+)>>/g;
var textContent = frame.contents;
var match;while ((match = placeholderPattern.exec(textContent)) !== null) {
var placeholder = match[1];// Safely handle placeholder
if (placeholder === null || placeholder === undefined) {
unresolvedPlaceholders.push(
"Invalid placeholder found in text frame index " + j
);
} else {
// Convert to string and remove leading/trailing whitespace
placeholder = placeholder.toString().replace(/^\s+|\s+$/g, "");// Check if the placeholder matches a valid field name
if (!arrayContains(validFieldNames, placeholder)) {
unresolvedPlaceholders.push(
"Unresolved placeholder: <<" + placeholder + ">> in text frame index " + j
);
}
}
}
}// Display results
if (unresolvedPlaceholders.length > 0) {
var message = "Unresolved Placeholders Detected:\n\n" + unresolvedPlaceholders.join("\n");
alert(message);
} else {
alert("All placeholders are resolved successfully!");
}
} catch (e) {
alert("An error occurred: " + e.message);
}
}// Run the function
detectAllUnresolvedPlaceholders(); -
John C commented
David Curious. I have a question. Hit me up at john@jjcstudios.com
-
Forlorn Photos commented
When creating an InDesign merge document, be sure to select the fields from the list that is generated after you select a data source. Double click on the field name in the list to place it into your document. Don't try to freestyle by typing them manually. I often get the placeholder error when opening a previously saved file that has outdated (or invalid) field names. All it takes is one bad one and the merge will fail even if all the others are valid. When in doubt, run a test by placing the merge fields into a completely blank document and trying to run preview from there. Remember, when you get the placeholder error, the problem is your InDesign layout, not the data file. Hope this helps.
-
David Curious commented
if anyone pay me, i can write a script to do that.:)
-
Matthew Anacleto commented
Had came across this issue today. I solved it deleting all placeholder frames and using the move pages to a new document. I had object styles for all the elements so it was a snap re-building.
-
Andre commented
Great idea, avoid having to cross check the CSV and data labels!
-
Anonymous commented
Worst game of hide and go seek ever! Come on make a noise little link!
-
JD commented
I have the same issue and am unable to find the cause. It is inconsistent, sometimes it works, other times not. Agree entirely that Adobe should at a minimum highlight where the problem is to simplify troubleshooting!
-
Vicky commented
I'm experiencing the same error as the previous user - It worked, then it didn't. I'm not using real info, just testing out a few columns.
-
Anonymous commented
I'm also having this issue and just testing with 4 cells filled in with information, 2 row, 2 column + title and it's messing up. It worked and then it didn't