通过 netsuite 访问 FTP
Accessing FTP through netsuite
我想在 NetSuite 上安排一个脚本,以从 FTP 位置上传和下载 txt 文件。我可以创建一个文件并将其存储在文件柜中,但这是我所能做到的。
我有点新,完全不知道是否可以从 NetSuite 安排 FTP?
遗憾的是,无法FTP访问 NetSuite。
不过,您可以使用预定脚本或 Web 服务解决该限制。
这是之前的 post,其中包含有关如何启动预定脚本的示例代码:How to upload a file to Netsuite File Cabinet Automatically?
- 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.
在 SuiteScript 2.0 中,您可以使用 N/sftp 模块 upload/download 到 SFTP 位置。这是我为客户使用的一段代码。
var csvfile = file.create({
'name': 'transactions.csv',
'fileType': file.Type.CSV,
'contents': filecontents
});
var conn = sftp.createConnection({
'username': username,
'passwordGuid': passwordGuid,
'url': url,
'directory': directory,
'hostKey': hostkey
});
conn.upload({
'file': csvfile,
'replaceExisting': true
});
我想在 NetSuite 上安排一个脚本,以从 FTP 位置上传和下载 txt 文件。我可以创建一个文件并将其存储在文件柜中,但这是我所能做到的。
我有点新,完全不知道是否可以从 NetSuite 安排 FTP?
遗憾的是,无法FTP访问 NetSuite。
不过,您可以使用预定脚本或 Web 服务解决该限制。
这是之前的 post,其中包含有关如何启动预定脚本的示例代码:How to upload a file to Netsuite File Cabinet Automatically?
- 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.
在 SuiteScript 2.0 中,您可以使用 N/sftp 模块 upload/download 到 SFTP 位置。这是我为客户使用的一段代码。
var csvfile = file.create({
'name': 'transactions.csv',
'fileType': file.Type.CSV,
'contents': filecontents
});
var conn = sftp.createConnection({
'username': username,
'passwordGuid': passwordGuid,
'url': url,
'directory': directory,
'hostKey': hostkey
});
conn.upload({
'file': csvfile,
'replaceExisting': true
});