How are you getting that document id? In my experience, the ID is only relevant for the life of the open document. It seems to indicate the order in which the document was opened; in fact, closing and reopening the same document results in an ID that has changed by +1.
Perhaps you could try refreshing the document id each time you use this?
I am finding the same thing as well. Now I am just using a script to update the id portion and continue.
resolve(specifierValue.replace(new RegExp("@id=\\d+", "gi"), '@id=' + doc.id));
I'd think it would be simpler to just record the pageItem id and use doc.pageItems.itemByID(savedID) to get it later.
Awesome didn't know that this existed. I'll give it a shot. Thanks Harbs
It doesn't seem to work well with table cells.
When I use cells[cellIndex].id I get back a value of 4. When I later use this it gets returned as a PageItem and then later fails.
Do table cells not have their own unique identifier?
They have (sort of), but the scope of the ID is limited to Cells (Cells do not belong to the PageItems Class !) and to the Table they are sitting in.
To address a specific cell in a specific table, you could address the table and the specific cell by its index:
var myCell = mySpecificTable.cells[n];
Or by its ID:
var myCell = mySpecificTable.cells.itemByID(n);
Or by its name:
var myCell = mySpecificTable.cells.itemByName("IndexNumberOfCellInRow:IndexNumberOfRowInTable");
In the case of merged cells over different rows, the number of the index and the ID number of the cell will not match!
Table cells ids are not the same as page item ids. Page item ids are the underlying UIDs of the Spline items on the C++ level. All objects in InDesign are stored in a database and identified by their ids. (InDesign is a transactional database at its core.) Table cells are simply reference counted within their parent structure and the ids are all generated on the fly. Tables are actually very expensive objects to deal with in InDesign...