I want to load an existing file and append some data, save it back. Tried following in SuiteScript 2.0. But following code still gives me old file content ( only first line when it was created !). Whats wrong?
var fileObj = file.load({
id:'SuiteScripts/MergeVendorResults/'+'MergeResult_'+recordId+'.txt'
});
var oldFileContents = fileObj.getContents();
log.debug("Existing file contents","Old File Contents -> "+oldFileContents);
fileObj.contents = oldFileContents + "\n"+ fileContents;
var id = fileObj.save();
fileObj = file.load({
id: id
});
log.debug("Existing file replaced with contents","File Contents -> "+fileObj.getContents());