Highlighted

CS3 to CC 2019

New Here ,
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?

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.

TOPICS
Scripting, Server developers

Views

130

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

CS3 to CC 2019

New Here ,
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?

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.

TOPICS
Scripting, Server developers

Views

131

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
Jul 15, 2020 0
Adobe Community Professional ,
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 )

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...
Jul 15, 2020 0
New Here ,
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

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...
Jul 15, 2020 0
Adobe Community Professional ,
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 )

 

 

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...
Jul 15, 2020 0
New Here ,
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

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...
Jul 15, 2020 0
Adobe Community Professional ,
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 )

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...
Jul 15, 2020 0
New Here ,
Jul 15, 2020

Copy link to clipboard

Copied

Thank you for the links, Uwe Laubender

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...
Jul 15, 2020 0
Adobe Community Professional ,
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

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...
Jul 15, 2020 0
Adobe Community Professional ,
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 )

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...
Jul 15, 2020 0