Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Scripting - Insert Loaded Datamerge placeholders into text frame

New Here ,
Mar 18, 2025 Mar 18, 2025

Hi everyone, 
Hoping someone here can help me. I am writing a script to automate a process that takes way too much out of my day... 

I need the data that is loaded into the datamerge window, to insert into a text frame AND link up.
At the moment I can get the text to populate based on the data, but it doesnt retain a link, can't figure out what to reference. 

Screenshot 2025-03-18 at 13.59.47.pngexpand image
Any ideas?
Thanks!




TOPICS
How to , Scripting
125
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2025 Mar 18, 2025

I do not believe there is a way to insert a DM field into a frame. Your best bet is to roll ypur own DM by reading the txt or csv file using the File object and dynamically creating your document that way. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2025 Mar 19, 2025

@brian_p_dts

 

Each DataMerge Placeholders collection - has add() method.

 

1000030652.jpgexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2025 Mar 19, 2025

I stand corrected. Must be thinking of something else. I don't oft script DM.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2025 Mar 18, 2025

Have you checked this post? I think they are trying to do the same thing:

 

https://community.adobe.com/t5/indesign-discussions/using-a-script-to-access-indesign-s-datamerge-fi...

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2025 Mar 20, 2025
LATEST

Hi @AidanCable ,

there is a way to do that by ExtendScript scripting.

 

In 2018 Loic Aigon posted some code in the InDesign Scripting forum (later it that forum was merged to what you see now as InDesign User Forum ). That script, so I remember, does exactly what you want. It looked up texts like you wrote with contents <<fieldname>> where fieldname is the name of a datamerge field. Loic's script finally added datamerge text placeholders according to the field name.

 

Well, but I think that this thread is not available anymore.

At least I cannot find it…

 

As @Robert at ID-Tasker already said:

There is a method add() with object dataMergeTextPlaceholders:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#DataMergeTextPlaceholders.html#d1e73552__...

 

It needs three parameters:

parentStory

storyOffset

field

 

Important notes:

In case the datamerge text placeholder should be added to text in a table text cell, be careful what you do with parameter parentStory. My guess is, that you need parent.texts[0] in case of a table text cell. And not the usual property parentStory. Had no time to do further testing…

 

BTW: storyOffset in fact is actually a insertionPoint.

The documentation I linked to is a bit misleading or hard to understand in this regards.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

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