Skip to main content
JHoag
Participating Frequently
January 8, 2018
Answered

How to resolve Warning JavaScript Window Invalid File Location Error

  • January 8, 2018
  • 2 replies
  • 8290 views

Apologies in advance as I have little JavaScript experience. A JavaScript was created by another coworker who also has little JavaScript experience and propagated to a specific file server folder/share location on our domain network. The script forces users to open PDF documents from this specific location and so prevents users from creating copies of what would be otherwise outdated documents (As was previously the issue). This script also auto time-stamps and closes the document after being printed. All of these JavaScript PDF's are accessed by our domain users via a Microsoft Access database (hyperlinks). These hyperlinks link directly to the file server folders where these JavaScript PDF's are located. This has worked without issue for some time but something has changed. The issue is that something has occurred that now prevents the PDF's with this JavaScript from opening. An error now appears (Warning: JavaScript Window - Invalid File Location). I can see the portion of code causing the prompt and the PDF will open if this portion is removed, however, they want the functionality of it to work as intended. It appears that windows accounts on any domain user computer that were created before this issue surfaced can still open these JavaScript PDF files, however, all newly created Windows accounts on any domain computer for both existing and new users experience the error/issue.  I have pasted the script being used below. I have emboldened the error. I am hoping someone has an idea as to what may be happening.

//-------------------------------------------------------------

//-----------------Do not edit the XML tags--------------------

//-------------------------------------------------------------

//<Document-Level>

//<ACRO_source>load</ACRO_source>

//<ACRO_script>

/*********** belongs to: Document-Level:load ***********/

var allowedPath = "/SERVER/DIRECTORY/FOLDER/";

if (this.path.indexOf(allowedPath)!=0) {

    app.alert("Invalid file location!");

    this.closeDoc(true);

}

//</ACRO_script>

//</Document-Level>

//<Document-Actions>

//<ACRO_source>Document Will Print</ACRO_source>

//<ACRO_script>

/*********** belongs to: Document-Actions:Document Will Print ***********/

    var f = this.getField("DatePrinted");

    f.hidden = false;

    f.value = "Printed on: " + util.printd("HH:MM dddd, dd mmmm, yyyy", new Date());

    this.dirty = false;

    this.closeDoc(true);

//</ACRO_script>

//</Document-Actions>

This topic has been closed for replies.
Correct answer try67

Maybe they are opening the file from a local folder, instead of the network folder?

Also, keep in mind that JS is case-sensitive, so if the network folder is mapped with lower-case letters instead of upper-case ones (as it appears in the code), it's not going to work.

2 replies

Karl Heinz  Kremer
Community Expert
Community Expert
January 8, 2018

Has the path to the document changed? One thing you could do is show what the path is before closing the document. You can do that by either printing to the console, or by adding the path to your message dialog.

Here is a combination of both solutions:

var allowedPath = "/SERVER/DIRECTORY/FOLDER/";

if (this.path.indexOf(allowedPath)!=0) {

     console.println("Path is " + this.path);

    app.alert("Invalid file location!\nPath = " + this.path);

    this.closeDoc(true);

}

This way you can see why the scripts assumes that the location is not valid.

JHoag
JHoagAuthor
Participating Frequently
January 8, 2018

I will try this out. The path has not changed and still works for any user on a windows domain account that had setup the account prior to this issue surfacing. When exactly it surfaced I do not know. Thank you.

Bernd Alheit
Community Expert
Community Expert
January 8, 2018

When you open a PDF file you can see the location at File > Properties > Description

Bernd Alheit
Community Expert
Community Expert
January 8, 2018

You will get the message when /SERVER/DIRECTORY/FOLDER/ is not part of the file paths.