Skip to main content
Ryan_Oliver_02445
Known Participant
January 18, 2019
Answered

How to print Javascript strings into console, or into a txt file

  • January 18, 2019
  • 2 replies
  • 14082 views

Good evening, I am trying to find a way to print the strings in my Javascript into the console log, that, or print the strings into a txt file.

Here is what I have so far:

var File = this.documentFileName.replace(/.pdf/,"");

var First = this.getField("First Name");

var Last = this.getField("Last Name");

var Middle = this.getField("Middle Initial");

var State = this.getField("State");

var Lab = "MDV";

if (State = "AL" && "CT" && "FL" && "GA" && "HI" && "IL" && "KY" && "LA" && "MD" && "DC" && "MI" && "MN" && "NJ" && "NM" && "NC" && "OR" && "SC" && "TX" && "UT" && "VA" && "WY") {   

    lab = "HELIX";

}

var Patient = Last + ", " + First + " " + Middle + " - " + Lab + " - " + State + " - " + "REC FORM";

I am looking for a way to print the variable, "File" so that we can see which files are not correctly spelled, and so that our checkers can correct the files later on.

This topic has been closed for replies.
Correct answer try67

Use this code:

console.println(File);

2 replies

try67
Community Expert
January 18, 2019

PS. You have multiple errors in your code...

Ryan_Oliver_02445
Known Participant
January 18, 2019

I've found that I do have quite a few errors.  One of them is that, "this.documentFileName is undefined" in the console.

Do you mind if I ask, if there is a fix for this issue? 

try67
Community Expert
January 18, 2019

That's actually fine... However, it will only work if you have a document open at the time you run the code, of course.

try67
try67Correct answer
Community Expert
January 18, 2019

Use this code:

console.println(File);