Copy link to clipboard
Copied
Hi,
I have some javascript code that I am porting from CS3 to CS5.
The code was working well on a Windows Server as CS3.
I have ported this to run fine on my local Mac machine on CS5.
As soon as I try to run this on a Mac Server running CS5 I get issues.
Here is the original code snippet.
template = File("/myDirectory/sample_template.indd");
document = app.open(template, true);
The file exists and template.exists is combing back as 'true'.
The error logging coming back is this:
Error: Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE., Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE.
I have tried the following code variations with the following results in red.
document = app.open(template);
Error: Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE., Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE.
document = app.open(template, OpenOptions.OPEN_ORIGINAL);
Error: defaultValue is undefined, defaultValue is undefined
document = app.open(template, OpenOptions.openOriginal);
Error: defaultValue is undefined, defaultValue is undefined
document = app.open(template, OpenOptions.openCopy);
Error: defaultValue is undefined, defaultValue is undefined
I am running this as CS5 (app.scriptPreferences.version = 7;)
Any ideas why app.open() is failing?
Carlos
The arguments to app.open() are different under InDesign server. See: http://jongware.mit.edu/idcs5serv_html_3.0.3d/idservcs5/pc_Application.html#open.
Unsurprisingly, the showingWindow option is omitted, because InDesign Server never shows windows.
Copy link to clipboard
Copied
Hi
You should not omit ShowingWindow in CS5 when use OpenOptions.
"document = app.open(template)" must be used default value to options, why Error?
CS3
app.open(from, [showingWindow])
document = app.open(template);
document = app.open(template, true);
CS5
app.open(from, [showingWindow], [openOption])
document = app.open(template);
document = app.open(template, true);
document = app.open(template, true, OpenOptions.OPEN_ORIGINAL);
document = app.open(template, true, OpenOptions.OPEN_COPY);
Copy link to clipboard
Copied
The arguments to app.open() are different under InDesign server. See: http://jongware.mit.edu/idcs5serv_html_3.0.3d/idservcs5/pc_Application.html#open.
Unsurprisingly, the showingWindow option is omitted, because InDesign Server never shows windows.
Copy link to clipboard
Copied
So the general solution which works for me is to check for Server vs Desktop
and use the appropriate parameter list. Something like this:
if (isInDesignServer == true)
{
document = app.open(template, OpenOptions.OPEN_COPY);
}
else
{
var showWindow = false;
document = app.open(template, showWindow);
}
thanks guys.
Copy link to clipboard
Copied
It seems like there should be a better way but I don't see one.
I suppose while this could conceivably be a design error, trying
to fix it in the next version doesn't seem like a good idea either,
so there's really nothing we could ask Adobe to do to improve the
situation, right?
Copy link to clipboard
Copied
What does app.version return on ID Server?
Copy link to clipboard
Copied
It returns "7.0.4.553" -- what were you expecting?
Copy link to clipboard
Copied
Ah yuck. Well, something like "7.0.4.553 Server". Mind, it has always been advertised as "The application version (string)", not "number" or something.
Okay, then use hasOwnProperty on the Application object? There must be something that Server has and Desktop not -- or the reverse. Would app.hasOwnProperty("activeDocument") do something useful?
Copy link to clipboard
Copied
Are we now looking for a way to see if the version running is Server or Desktop?
If so, I use this test:
isServer = (app.fullName.toString().indexOf("Server") > -1);
If not, ignore this message.
Copy link to clipboard
Copied
Like swingcarlos, I'm a bit confused what problem you're trying to solve, Jongware. He's already got a way to tell.
Though I would probably use application.hasOwnProperty("serverSettings"), but it probably doesn't matter much.
What would be nice would be an open() method with compatible type signatures on both. But it seems clear we're not going to have that.
(There's also app.serverTest(), but I don't know what that does... Ah well...)
Oh, and in case you're curious about app.fullName:
app.fullName
Result: /Applications/Adobe%20InDesign%20CS5.5%20Server/InDesignServer.app
decodeURI(app.fullName)
Result: /Applications/Adobe InDesign CS5.5 Server/InDesignServer.app
app.version
Result: 7.5.0.142