问题
How can I upload a file to Netsuite File Cabinet automatically?
would nLapiRequestURL("Server1/database1/NDT/ftp.csv
work?
File is to be fetched from a server within company.
I need to import CSV file to the cabinet automatically once a day.
回答1:
I think that the simplest way to go about this is:
- Place your CSV file into a location that is publicly visible(obviously, this only works if it's not sensitive information! PLEASE PLEASE PLEASE don't do this if you don't want the whole world to see it!)
- Create a scheduled script in NetSuite. Set the deployment to run daily, at whatever time you deem best
- In your scheduled script, use nlapiRequestUrl (NS help doc) to get the file from wherever you placed it (Note that there is a 5mb size limitation!)
- Use nlapiCreateFile (NS help doc) to create a file
- Use nlapiSubmitFile (NS help doc) to submit it to the file cabinet
Sample code:
var response = nlapiRequestURL('http://yourserver.yourcompany.com/somecsvfile.csv');
var csvDataInBase64 = response.getBody();
var file = nlapiCreateFile('mycsv.csv', 'CSV', csvDataInBase64);
nlapiSubmitFile(file);
There is no error checking or anything in that sample, but it should get you started.
If security matters(see point 1 above!), you are likely best off sending the file via web services. See https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/SuiteTalkWebServices.html for more information.
来源:https://stackoverflow.com/questions/26289397/how-to-upload-a-file-to-netsuite-file-cabinet-automatically