如何自动将文件上传到 Netsuite 文件柜?
会nLapiRequestURL("Server1/database1/NDT/ftp.csv
工作?
文件将从公司内部的服务器获取。
我需要每天自动将CSV文件导入内阁一次。
最佳答案
我认为最简单的方法是:
- 将您的 CSV 文件放入公开可见的位置(显然,这仅在不是敏感信息时才有效!如果您不想让全世界都看到它,请不要这样做!)<
- 在 NetSuite 中创建计划脚本。将部署设置为每天运行,无论您认为什么时间最好
- 在您的计划脚本中,使用 nlapiRequestUrl (NS help doc)从您放置的位置获取文件(请注意,有 5mb 大小限制!)
- 使用 nlapiCreateFile (NS help doc)创建一个文件
- 使用 nlapiSubmitFile (NS help doc)将其提交至文件柜
示例代码:
var response = nlapiRequestURL('http://yourserver.yourcompany.com/somecsvfile.csv');
var csvDataInBase64 = response.getBody();
var file = nlapiCreateFile('mycsv.csv', 'CSV', csvDataInBase64);
nlapiSubmitFile(file);
该示例中没有错误检查或任何内容,但它应该可以帮助您入门。
如果安全很重要(请参阅上面的第 1 点!),您可能最好通过网络服务发送文件。请参阅https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/SuiteTalkWebServices.html了解更多信息。
关于javascript - 如何自动上传文件到Netsuite文件柜?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26289397/