Highlighted

How can InDesign rename each form field after a Data Merge?

New Here ,
Apr 22, 2019

Copy link to clipboard

Copied

Hello,

Running Indesign CC:

I have made an Indesign Data Merge Document that I would like to convert to an interactive pdf file. I have a text field form as a part of my Data Merge. When I create my merged document, all of my data comes in perfectly. However my Text Field Form comes in with the same text field name. Which is a problem, because once I use the Interactive pdf file and insert a number into the Text Form Field, the entire catalogue populates with the same data. I understand why that is due to naming.

My question: Is there some preparation I can do with my data to prepare Text Field Forms before running my Data Merge? Or is there a way to rename each Text Field Form in one swoop after my merged document? I have seen many tutorials saying I have to rename each field individually and one at a time. This proves to be difficult as there will be thousands of items showcased.

I hope this message is clear.

Look forward to your help.

Thanks,

Warren

Adobe Community Professional
Correct answer by Colin_Flashman | Adobe Community Professional

I'm guessing that the data merge is going into one large file, rather than lots of individual files. If that's the case, there is a javascript that can rename all text fields in a document. Go to this thread: inDesign CS6 - changing button description ( tooltip ) using JavaScript  and use the script in post 4 of the thread. You will need to replace the word buttons with textBoxes (spelled as you see it here). I've tried it on a test document that I made. The only issue will be is if there are several form fields on a page, the naming will start from the bottom right and zig-zag in an opposite reading order... but if the names aren't important and its reading order will be determined elsewhere, this should be fine.

Here is the amended script with full thanks to its original author at the earlier linked thread.

function updatetextBoxes()  
{  
     var myDoc = app.activeDocument;  
     var textBoxes = myDoc.textBoxes;  
     for (var i = 0; i < textBoxes.length; i++)  
     {  
          var btn = textBoxes;  
          btn.name = "New Name " + i;  
          btn.description = "New Description " + i;  
     }  
}  
updatetextBoxes()

Views

674

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How can InDesign rename each form field after a Data Merge?

New Here ,
Apr 22, 2019

Copy link to clipboard

Copied

Hello,

Running Indesign CC:

I have made an Indesign Data Merge Document that I would like to convert to an interactive pdf file. I have a text field form as a part of my Data Merge. When I create my merged document, all of my data comes in perfectly. However my Text Field Form comes in with the same text field name. Which is a problem, because once I use the Interactive pdf file and insert a number into the Text Form Field, the entire catalogue populates with the same data. I understand why that is due to naming.

My question: Is there some preparation I can do with my data to prepare Text Field Forms before running my Data Merge? Or is there a way to rename each Text Field Form in one swoop after my merged document? I have seen many tutorials saying I have to rename each field individually and one at a time. This proves to be difficult as there will be thousands of items showcased.

I hope this message is clear.

Look forward to your help.

Thanks,

Warren

Adobe Community Professional
Correct answer by Colin_Flashman | Adobe Community Professional

I'm guessing that the data merge is going into one large file, rather than lots of individual files. If that's the case, there is a javascript that can rename all text fields in a document. Go to this thread: inDesign CS6 - changing button description ( tooltip ) using JavaScript  and use the script in post 4 of the thread. You will need to replace the word buttons with textBoxes (spelled as you see it here). I've tried it on a test document that I made. The only issue will be is if there are several form fields on a page, the naming will start from the bottom right and zig-zag in an opposite reading order... but if the names aren't important and its reading order will be determined elsewhere, this should be fine.

Here is the amended script with full thanks to its original author at the earlier linked thread.

function updatetextBoxes()  
{  
     var myDoc = app.activeDocument;  
     var textBoxes = myDoc.textBoxes;  
     for (var i = 0; i < textBoxes.length; i++)  
     {  
          var btn = textBoxes;  
          btn.name = "New Name " + i;  
          btn.description = "New Description " + i;  
     }  
}  
updatetextBoxes()

Views

675

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 22, 2019 0
Adobe Community Professional ,
Apr 23, 2019

Copy link to clipboard

Copied

I'm guessing that the data merge is going into one large file, rather than lots of individual files. If that's the case, there is a javascript that can rename all text fields in a document. Go to this thread: inDesign CS6 - changing button description ( tooltip ) using JavaScript  and use the script in post 4 of the thread. You will need to replace the word buttons with textBoxes (spelled as you see it here). I've tried it on a test document that I made. The only issue will be is if there are several form fields on a page, the naming will start from the bottom right and zig-zag in an opposite reading order... but if the names aren't important and its reading order will be determined elsewhere, this should be fine.

Here is the amended script with full thanks to its original author at the earlier linked thread.

function updatetextBoxes()  
{  
     var myDoc = app.activeDocument;  
     var textBoxes = myDoc.textBoxes;  
     for (var i = 0; i < textBoxes.length; i++)  
     {  
          var btn = textBoxes;  
          btn.name = "New Name " + i;  
          btn.description = "New Description " + i;  
     }  
}  
updatetextBoxes()

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 23, 2019 1
New Here ,
Apr 23, 2019

Copy link to clipboard

Copied

Thank you very much, Colin. Appreciate you taking the time.

This worked incredibly well.

Warren

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 23, 2019 0
New Here ,
Apr 10, 2020

Copy link to clipboard

Copied

Hi! Thank you so much for script. Unfortunately it doesn't work for me. I'm using ID 2020 (15.0.1) and I get the error when trying to run the script:

 

Error Number: 55
Error String: Object does not support the property or method 'name'
Line: 8
Source: btn.name = "New Name" +i;

 

Is there a way to make it work?

 

Thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2020 0
New Here ,
Sep 27, 2020

Copy link to clipboard

Copied

Hi,

 

I have the same issue and error message with the script on ID 2020.

Did you find any answer to your question or any property/command/script to use ?

I am still investigating the documentation but without any success..

 

Thank you 

Eric

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 27, 2020 0
New Here ,
Sep 27, 2020

Copy link to clipboard

Copied

Hi Eric,

 

Sorry, didn't find the solution. I think I ended up renaming all fields manually.

 

Artem

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 27, 2020 0
Adobe Community Professional ,
Sep 29, 2020

Copy link to clipboard

Copied

Hi together,

migrating this old thread from April 2019 to the new InDesign forum about a year ago damaged the posted code.

Below a version that should work ( not tested ). It comes with an Undo as well:

 

( function()
{
	
	app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
	app.doScript
	(
	
	updateNameAndDescriptionOfTextBoxes,
	ScriptLanguage.JAVASCRIPT, 
	[], 
	UndoModes.ENTIRE_SCRIPT, 
	"SCRIPT | Update Name and Description of TextBoxes Form Fields"
	
	);

function updateNameAndDescriptionOfTextBoxes()   
{   
	var myDoc = app.activeDocument;   
	var textBoxes = myDoc.textBoxes.everyItem().getElements();   
	var textBoxesLength = textBoxes.length;
	
	for (var n = 0; n < textBoxesLength; n++)   
	{   
		var currentTextBox = textBoxes[n];
		currentTextBox.name = "New Name " + ( n + 1 );   
		currentTextBox.description = "New Description "+ ( n + 1 );
	};
};

}() )

 

Regards,
Uwe Laubender

( ACP )

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 29, 2020 0