If set file type to "t" then attach a txt file by Javascript, all the line feed will be missed.

  • KM02779794
  • 21-Apr-2017
  • 21-Apr-2017


If set file type to "t" then attach a txt file by Javascript, all the line feed will be missed.


Customer created a Javascript to attach attachment file.
In order to make the Javascript work, they added a table to specify the details of attachment, like the filename, the path, and the type of the file.
And at this table, one field is to set the type to "t"(text) or "b"(binary) to the file to be attached.
If we set type "t"(text) to a txt file, then attach this text file through the Javascript,
we will find all the line feed will be missed in the file.


QCCR1E138093 was opened to located this problem.

According to the comments of the lab, type "t" is used by writeFile to write file to external.
When read file to SM, all the files will be proceeded in binary, so we need to set type "b" not type "t" to text file in this case.

Lab has also updated help article "JavaScript method: SCFile.insertAttachment( attachObj )" to clarify this.

the origianl line:
Attachment.value: This is a binary string containing the actual attachment data. One way to obtain such data is by using the readFile() global method.

after updated:
Attachment.value: This is a binary string containing the actual attachment data. One way to obtain such data is by using the readFile() global method with the binary file format (readFile(path,"b")).

The updated help article can be downloaded at