Hi all! I need to write a search result in JSON fo...
# suitescript
k
Hi all! I need to write a search result in JSON format to a file in the filecabinet. The documentation for N/file only has examples for create. How do you write to an existing file?
a
load the file, set the contents, save the file
k
myFile.contents = 'some string'?
I tried that and nothing hit the file
a
huh, actually that sounds familiar, i think i remember you just create a new file with the new contents, and delete teh old file
e
You can't.
contents
is read-only
k
That's what I thought
so I'm using file.create instead
and trying to save over the same name
a
right if you wanna reuse the file name you'd have delete the original file
k
oh duh, classic map / reduce mistake. Forgot to include a try/catch
Copy code
SSS_FILE_CONTENT_SIZE_EXCEEDED
👎 1
Well, that explains it
Did it as a CSV of just the internal IDs and it worked! 😄
🎉 1