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

InDesign Script is not working any more with update 2020 to 2021 on InDesignServer

Explorer ,
Jan 31, 2022 Jan 31, 2022
Dear Community,
 
I have a simple code to delete all unused layers, swatches and more. After the update InDesign Server 2020 to 2021 deleting swatches it is not working any more. The rest scripts are working. For example delate different layer. 
On InDesign Desktop it is working. 
Is this a bug on this server version, or how can I fix it? I also tried out to delete swatches with function options. It is not working too.
 
System: OSX
 
var myDoc = app.documents.firstItem();
for(i=myDoc.unusedSwatches.length-1;i>=0;i--)
{
myDoc.unusedSwatches[i].remove();
}
TOPICS
Bug , Scripting
1.1K
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 ,
Jan 31, 2022 Jan 31, 2022

Hi @Nobat5C29, I've never used Indesign Server, so we might have to wait for an expert, but a perhaps there's a couple of things you could try. One is to write to the console to check that anything is happening, eg. maybe it isn't storing unused swatches? Another is (long shot!) to copy the Document.unusedSwatches to a normal array before removing it in case there is a referencing problem as the swatches are removed.

- Mark

 

var myDoc = app.documents.firstItem();

// copy to an array
var unusedSwatches = [];
for (var i = 0; i < myDoc.unusedSwatches.length; i++) {
    unusedSwatches.push(myDoc.unusedSwatches[i]);
}

for (var i = unusedSwatches.length - 1; i >= 0; i--) {

    // this line should write to the console in Indesign Server
    app.consoleout("Removing unused swatch " + unusedSwatches[i].name);

    unusedSwatches[i].remove();
}
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 ,
Jan 31, 2022 Jan 31, 2022

The code looks fine and as you say it works on CC2020 then this makes it more interesting. As @m1b mentioned did you do some more debugging around this issue. Predominantely the following are the points that I would look into before coming to a conclusion that this is a bug.

  • Did you try the same code snippet on the same InDD document on both CC2021 and CC2022 IDS versions? We need to make sure that even the document on which the code is working is the same across our tests
  • Does CC2021 give a valid list of unsusedswatches or is the list empty?
  • Any message on the console when you execute the remove method. Maybe you could use a try catch block and log message in the catch section?
  • Are you able to delete swatches at all in CC2021 IDS? Or is this problem restricted to just unusedswatches?

Hope looking at these points and what @m1b pointed we more closer to a conclusion.

-Manan

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
Explorer ,
Feb 01, 2022 Feb 01, 2022

I made a lot of different Tests with a reseller, who could try different versions and we found out, it depens on the InDesign Server insalation language in the higher verssions 16. and 17. In Version 15 everythink is working fine. 
The Skritpt is working on InDesign Server Version 15, 16 and 17 english insallation, and Version 15 german insallation.

The Skript is not working on InDesign Server Version 16 and 17 in german insallation. I did an oher debug with this output:

Script result (std__string): 
Lösche ungenutztes Farbfeld: 21700 – '' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21699 – '' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21698 – '' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21697 – '' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21696 – '' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21705 – 'C=80 M=80 Y=0 K=0' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21704 – 'C=20 M=20 Y=10 K=0' >> Diese Farbe kann nicht gelöscht werden.
Lösche ungenutztes Farbfeld: 21703 – 'C=10 M=10 Y=20 K=0' >> Diese Farbe kann nicht gelöscht werden.
At the end it depend on the server language. I will check it out with the customer if we can change this. In the end it  does not matter in witch language the Server is running. In my opinion, it is a bug. 
Thank you for your advises.
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
Explorer ,
Feb 02, 2022 Feb 02, 2022

last update: it is does not matter witch language is. It madders with the InDesign Server Version. InDesign Server 16.0 is working. InDesign Server 16.2.1 is not working. 

In english Verion i get this errors:

Script result (std__string): 
Lösche ungenutztes Farbfeld: 21700 – '' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21699 – '' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21698 – '' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21697 – '' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21696 – '' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21705 – 'C=80 M=80 Y=0 K=0' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21704 – 'C=20 M=20 Y=10 K=0' >> This color cannot be deleted.
Lösche ungenutztes Farbfeld: 21703 – 'C=10 M=10 Y=20 K=0' >> This color cannot be deleted.
 
I am shure it is a bug. I will do more Tests
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 ,
Feb 02, 2022 Feb 02, 2022

Sounds like you are getting close to nailing down the issue. I assume you have tested the script with various documents, including a very simple one that you can document step-by-step how you made it. Then you can report the bug and include all the specifics of when it occurs in which version of Indesign Server etc.

- Mark

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
Advocate ,
Feb 12, 2022 Feb 12, 2022

It looks like a bug to me as well. Need to report.

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 ,
Apr 28, 2023 Apr 28, 2023

Hi together,

I came accross an issue that perhaps is related though, I see it in the current dektop version of my German InDesign 2023 on macOS ( had no chance to test with earlier versions or with a Windows version; will do later ) .

 

There is this feature Merge Swatches in the GUI. And also method merge() with Colors and Swatches in ExtendScript.

If you do this with unused swatches the remaining swatch in NOT listed in the unusedSwatches array.

The GUI will not select the remaining swatch as unused with menu command Select All Unused in the Swatches panel.

 

To see this with a new, default document:

 

[1] Add a new document.

[2] Open the Swatches panel.

[3] Use the menu command "Select All Unused".

[4] Use the menu command "Merge Swatches".

All selected swatches will be merged to one of the selected ones.

In our default document with a default German InDesign the remaining swatch of all removable swatches will be:

"C=0 M=0 Y=100 K=0".

[5] Use the menu command "Select All Unused".

 

Result: No swatch will be selected.

Is this a bug? And if not, where is the remaining swatch used?

 

Inspect the array app.documents[0].unusedSwatches.

The color named C=0 M=0 Y=100 K=0 is not listed.

 

Note: The array is perhaps not empty, because there could be unnamed colors that are not used and therefore are listed.

 

What I also tried in the GUI:

Find Colors > C=0 M=0 Y=100 K=0

Result: There are no instances found where the color is in use.

 

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
Community Expert ,
Apr 28, 2023 Apr 28, 2023

Hi again,

there is news with the case above.

Finally I could remove the remaining swatch of the previous merging of swatches.

I had to run the following script two times in a row:

 

( function()
{

app.doScript
(

	deleteUnusedColors, 
	ScriptLanguage.JAVASCRIPT, 
	[],
	UndoModes.ENTIRE_SCRIPT, 
	"Delete Unused Colors | SCRIPT"

);

function deleteUnusedColors()
{
	if( app.documents.length == 0 ){ return };
	var doc = app.documents[0];
	var unusedColorsArray = doc.unusedSwatches;

	for( var n=0; n<unusedColorsArray.length; n++ )
	{
		unusedColorsArray[n].remove();
	};
};

}() )

 

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
Community Expert ,
Apr 28, 2023 Apr 28, 2023

Attached four InDesign documents in the order:

 

1-DefaultDocWithUnusedSwatches.indd
2-UnusedSwatches-MERGED-with-GUI-command.indd
3-DeleteUnusedColors-SCRIPT-RUN-1.indd
4-DeleteUnusedColors-SCRIPT-RUN-2.indd

 

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
Community Expert ,
May 02, 2023 May 02, 2023
LATEST

Just another note:

I can see the issue with merging unused colors in the desktop version of InDesign 2020 and above.

For Windows and macOS.

 

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