How to upload a file to Netsuite File Cabinet Automatically?

懵懂的女人 提交于 2019-12-23 04:56:30

问题


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:

  1. 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!)
  2. Create a scheduled script in NetSuite. Set the deployment to run daily, at whatever time you deem best
  3. 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!)
  4. Use nlapiCreateFile (NS help doc) to create a file
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!