ディスカッション
Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.
SuiteScript 2.0 でRestletを使用し、NetSuiteファイルキャビネットからファイルをダウンロードして移動する
適用
製品: NetSuite 2022.1
シナリオ
開発者は、NetSuiteファイルキャビネットからファイルIDを取得するためのRestletを作成できます。ファイルIDは、ダウンロードして特定のフォルダに移動するためのRestlet呼び出し中にパラメータとして渡すことができます。以下のレストレットの例は、3つの操作をサポートしています。 PostパラメータはJSON形式で渡すことができます。ダウンロードできるファイルの最大サイズは10 MBであることに注意してください。
解決策
//処理可能なファイル内部IDを返します
{
"operation": "getFileIds"
}
//関連ファイルを宛先フォルダに移動します
{
"operation": "moveFile",
"id": xxx
}
//関連ファイルの内容を返します
{
"operation": "getFile",
"id": xxx
}
/**
* @NApiVersion 2.x
* @NScriptType Restlet
*/
var SAVED_SEARCH = 'customsearch_files_to_download';
var DESTINATION_FOLDER = 509;
define(['N/file', 'N/search'],
function (file, search) {
function post(dataIn) {
var operation = dataIn.operation;
if (operation == 'getFile') {
if (dataIn.id)
return getFile(dataIn.id);
else
return 'Request not processed. Details: ' + JSON.stringify(dataIn);
}
if (operation == 'getFileIds') {
return getFileIds();
}
if (operation == 'moveFile') {
if (dataIn.id)
return moveFile(dataIn.id);
else
return 'Request not processed. Details: ' + JSON.stringify(dataIn);
}
return 'Operation: ' + operation + ' not found.';