Hi, anyone tried to overwrite a file with same fil...
# general
m
Hi, anyone tried to overwrite a file with same file name, file type and folder using Suitescript 2.0?
s
I have done this in a Map/Reduce script. The old file is automatically replaced by the new one.
However, there are some browser caching issues that can leave some users seeing the old version of the file, if they ever opened it before the overwrite happened.
m
@scottvonduhn I'm using it in map/reduce also and cleared my cache but still im seeing the old version.
s
Thats strange. We essentially do the same thing in an SS 2.0 module, and it works as expected (The file is overwritten). I tested some sample code and I end up with a file containing only the last saved contents.
Copy code
var fileType = file.Type.PLAINTEXT;
var folder = <FOLDER ID>;
var name = 'test.txt';
file.create({ fileType: fileType, folder: folder, name: name, contents: 'First' }).save();
file.create({ fileType: fileType, folder: folder, name: name, contents: 'Second' }).save();
file.create({ fileType: fileType, folder: folder, name: name, contents: 'Last' }).save();