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

Script error in data merge output document

Community Beginner ,
Feb 08, 2024 Feb 08, 2024

A script (that I found online) that I use regularly doesn't work in a document resulting from a data merge. The script works perfectly in any other regular document. 

 

This is the script, to automatically delete all rows with a specific text ("*"):

var allStories = app.documents[0].stories;

var st = 0;

while(st < allStories.length){

    var allTables = allStories[st].tables;

    var tbl = 0;

    while(tbl < allTables.length){

        var allCells = allTables[tbl].cells;

        var cel = 0;

        while(cel < allCells.length){

            if(allCells[cel].contents.toString().toLowerCase().indexOf("*") != -1){

                allCells[cel].rows[0].remove();

                allCells =  allTables[tbl].cells;

                cel = -1;

                }

            cel++;

            }

        tbl++;

        }

    st++;

    }

 

And this is the error I get when running it on a data merged document:

 

Captura de Pantalla 2024-02-08 a las 17.28.11.png

 

Any one know why it's only happening on data merged documents? 

TOPICS
Bug , Scripting
159
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 Beginner ,
Feb 08, 2024 Feb 08, 2024
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
Participant ,
Feb 09, 2024 Feb 09, 2024
LATEST

Could you share a sample .indd file where the script isn't working?

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