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

CS3 to CC 2019

New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

We are migrating from CS3 Indesign to CC 2019. There are a bunch of ExtendScripts written for CS3 which do not work in CC 2019. I have tried setting app.scriptPreferences.version = "5.0" without luck.

 

Most of the JSX files are localted under <InDesign location>/Scripts/Startup Scripts/folder1/folder2/..

 

The request generally fails when trying to read/parse an XML.

cellxmlElement.xmlAttributes.item("somekey").value; - "ReferenceError: Object is invalid"

 

This is the first error I faced after the migration and there could be such scenarios in the subsequent tests. Is there a way to get ExtendScripts written in CS3 to work with CC 2019?

TOPICS
Scripting

Views

573

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
community guidelines

correct answers 1 Correct answer

Guru , Jul 17, 2020 Jul 17, 2020

Here's another example regarding your question:

aCell.xmlAttributes.item("attr_name").value; //works in CS3
aCell.parent.xmlAttributes.item("attr_name").value; //works in CC 2019

As far as I know (I can be wrong!), nothing has changed in InDesign since CS3 regarding XML so both lines should work in the same way in CS3 and, say, 2020.

Below is a screenshot of my previous test doc with only one change: I added the "attr_name" attribute to the parent of aCell which is Table in my case and assigned it t

...

Votes

Translate

Translate
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Hi uk_newbee,

you need a seasoned developer to do this.

Someone who understands the specifics of InDesign CS3 and the vast differences between the two versions.

Sometimes it's better to step back and write a totally new script.

 

FWIW: You already tried your best by assigning "5.0" to property version of the app.scriptPreferences.

Make sure you switch that value back if done in that script!

 

Regards,
Uwe Laubender

( ACP )

Votes

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Hi UWe Laubender,

Thanks for the update. Are CS3 JSX files supposed to work with CC 2019 by setting app.scriptPreferences.version=5.0? If yes, any reason why they don't work? I agree it makes sense to write new scripts if newer InDesign does not support older version JSX files.

 

Thanks

Votes

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
community guidelines
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

With version set to "5.0" the old scripts can only work to a specific extend.

If features were added, things were rearranged in the document object model, old bugs were fixed, new bugs were introduced, a particular script could fail, yes. The gap from version 5 to version 15 is simply a huge one.

 

Just one example: Nowadays document pages could be of different size.

What should a script for InDesign CS3 should make out of this fact?

This is a fundamental change in InDesign's architecture.

 

So, what I like to say is: If you are lucky a script would run ok.

Prepare a lot of time for testing.

 

Regards,
Uwe Laubender

( ACP )

 

 

Votes

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Thanks for the update. If I may ask, could you please point me to Extendscript documentation for CS3 and CC 2019? When I google, I only find this URL "http://jongware.mit.edu/idcs6js/pc_XMLElements.html"

 

Thanks

Votes

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
community guidelines
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

You were very close regarding CS3 DOM documentation. See here at Jongware's site:

http://www.jongware.com/idjshelp.html

 

Newer DOM documentation can be found with Gregor Fellenz' repository:

 

InDesign CC 2019 version 14.0:

https://www.indesignjs.de/extendscriptAPI/indesign14/#about.html

 

InDesign 2020 version 15.0.0.155:

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

 

Note, that 15.1.1.103 is the most current version today.

 

Regards,
Uwe Laubender

( ACP )

Votes

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Thank you for the links, Uwe Laubender

Votes

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
community guidelines
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Maybe Make It Run might help? Try converting it to CS5? 

 

https://indesignsecrets.com/get-your-old-scripts-running-again-with-make-it-run.php

Votes

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
community guidelines
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Hi Brian,

I assume that the "MakeItRun" script is also using the app.scriptPreferences.version property.

Further: One of the commenters said that the script refuses to work with InDesign 2020.

 

Regards,
Uwe Laubender

( ACP )

Votes

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
community guidelines
Guru ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Does your code use XML rules? If so, check the reference to the 'glue code'.

I remember in an old version was a bug in the code so I had to fix the path manually.

— Kas

Votes

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
community guidelines
New Here ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

Can you please help me where and how I can check if glue code is being used?

Votes

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
community guidelines
Guru ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

It's always at the top of the script, like so:

Kasyan_Servetsky_0-1594968261847.png

The glue code is located here:

Kasyan_Servetsky_1-1594968387125.png

Make sure the path is correct. See 'Preprocessor directives' on page 233 in JS tools guide.

 

Votes

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
community guidelines
New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Thanks for the info. There is no reference to use of glue code. However to give an idea of the issue,

 

aCell.xmlAttributes.item("attr_name").value; //works in CS3

 

aCell.parent.xmlAttributes.item("attr_name").value; //works in CC 2019

 

Since these are existing scripts, there are multiple areas I have to change the way XML is parsed in CC 2019. Any idea how to fix this issue?

Votes

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
community guidelines
Guru ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

>> There is no reference to use of glue code.

See the XML Rules section in InDesign Scripting SDK. BTW, sample scripts are also provided there.

Kasyan_Servetsky_0-1594996062885.png

 

>> Since these are existing scripts, there are multiple areas I have to change the way XML is parsed in CC 2019. Any idea how to fix this issue?

You can open all your scripts in ESTK and make a change in all open docs in one go, like so:

Kasyan_Servetsky_1-1594996423805.png

It's hard for me to tell you what goes wrong and how to fix it without having the script in question and a doc for testing.

 

 

Votes

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
community guidelines
Guru ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Looking at your code, I guess aCell is a cell in a table. Right?
Then cell has no xmlAttributes property! Instead you should use associatedXMLElement which has it. Let's assume a cell is selected:

Kasyan_Servetsky_0-1594997602215.png

Then the following code gets its attribute's value:

main();

function main() {
	var aCell = app.selection[0];
	var val = aCell.associatedXMLElement.xmlAttributes.item("attr_name").value;
}

Kasyan_Servetsky_1-1594997707580.png

 

 

 

Votes

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
community guidelines
New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Thank you for the update. That is correct, "aCell" is a Cell of the table. Your suggestions on XML Rules are really helpful. Is there a tool that can take XML as an input and we can apply the XML rules on top of it? This way it will help me debug the changes faster.

 

In the ExtendScript toolkit you have JSX code, where did you input the XML file?

Votes

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
community guidelines
New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

sorry, aCell is actually XMLElement. Sorry for confusion. aCell.reflect.name shows it as XMLElement

Votes

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
community guidelines
Guru ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Here's another example regarding your question:

aCell.xmlAttributes.item("attr_name").value; //works in CS3
aCell.parent.xmlAttributes.item("attr_name").value; //works in CC 2019

As far as I know (I can be wrong!), nothing has changed in InDesign since CS3 regarding XML so both lines should work in the same way in CS3 and, say, 2020.

Below is a screenshot of my previous test doc with only one change: I added the "attr_name" attribute to the parent of aCell which is Table in my case and assigned it the value of "my_another_value".

Kasyan_Servetsky_0-1595013173919.png

So, both lines make sense if the XML elements have the attribute called "attr_name".

In my example, they have different values:

aCell ( I assume it's associated XML element of a cell) — my_attr_value

and its parent (table) — my_another_value

 

However, if the attribute with this exact name is missing, you'll get the Object is invalid error because indeed the object you reference is invalid.

To avoid such a situation, you can validate the reference to the attribule, like this:

 

main();

function main() {
	var sel = app.selection[0]; // a cell is selected
	var aCell = sel.associatedXMLElement;

	var attr_1 = aCell.xmlAttributes.item("attr_name");	
	if (attr_1.isValid) {
		var val_1 = aCell.xmlAttributes.item("attr_name").value;
	}

	var aTable = aCell.parent;
	var attr_2 = aTable.xmlAttributes.item("attr_name");	
	if (attr_2.isValid) {
		var val_2 = aTable.xmlAttributes.item("attr_name").value;
	}
}

 

For example, here I removed the attribute from the table. Since the reference is invalid, line #15 (unlike #9) is skipped (note the green marker after the line number is missing).

2020-07-17_22-40-48.png

Hope it's clear now.

Votes

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
community guidelines
New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

LATEST

Thank you for your help. This makes sense now. Let me try it out with the XML I hold.

Votes

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
community guidelines