Hi All, Is there a way to add new columns and valu...
# suitescript
s
Hi All, Is there a way to add new columns and values in an existing .csv file using Suitescript 2.0? I'm using Schedule script to read and process the .csv file from File Cabinet. I need to update values/insert new values in each row and upload them back to the file cabinet. Any suggestions/references would help. Thanks.
t
@SMNCP There is no special API function to edit an existing file, you could take the details of the existing file and create a new file with the same details but changing the data field only and deleting the old file. var start = function(request, response) { var fileId = "107524";//get the existing file id var file = nlapiLoadFile(fileId); var data = file.getValue(); var name = file.getName(); var folderId = file.getFolder(); var fileType = file.getType(); nlapiDeleteFile(fileId);//delete the older file data += ",this is the appended data";//change the data var newFile = nlapiCreateFile(name, fileType, data);//create a new file with the same details newFile.setFolder(folderId); nlapiSubmitFile(newFile);//submit it }
n
^^ that's SS1.0... @SMNCP see my DM with some suggestions and code to create a JSON object in case that proves easier for you to work with.