2009-11-19 89 views
2

我有一個很大的產品列表,需要生成一個靜態文件,並在我的網站上有該文件。目前,我生成列表,並將其上傳到文件櫃。我希望自動化這個過程。我想安排一個SuiteScript每天晚上運行並生成這個列表並更新文件櫃中的文件。Netsuite Suitescript可以修改文件櫃中的文件嗎?

可以這樣做嗎?

謝謝

回答

3

您可以使用SuiteScript自動執行此過程。您將使用nlapiLoadFile和nlapiSubmitFile調用來完成它。如果您有大量的產品列表,您可能會遇到其他一些問題。您可能會受到治理限制,並需要開發此腳本,以便跟蹤進度並適當重新安排自己的時間。 SuiteScript搜索將只返回前1000條記錄。如果您的文件中包含超過1000個項目,則您可能需要在項目記錄上使用一個標記來跟蹤哪些項目保留用於導出。使用SuiteScript加載或創建文件時,文件大小目前有5MB限制。

+0

非常感謝。我準備好最後繼續前進。我已經完成了一些API文檔的閱讀。我的產品列表大約500件,我只需要幾列,所以我不認爲我會受到任何治理/規模的限制。你有什麼建議可以在哪裏找到執行此操作的示例腳本/代碼?在此先感謝您的幫助。 – Rob 2010-01-08 16:23:48

4

例SuiteScript創建一個文件:

var data = 'Your,CSV,File,Here'; 
var folderId = 519; // Your File Cabinet folder ID here 

// Create the file and add it to the folder 
var f = nlapiCreateFile('products.csv', 'CSV', data); 
f.setFolder(folderId); 
var id = nlapiSubmitFile(f); 

// If you want to attach the file to a record, you can do something like this: 
nlapiAttachRecord('file', id, 'customrecord_x', recordId); 
+0

謝謝文森特...我會檢查你提出的新建議的stackexchange社區。 – Rob 2010-10-19 17:56:37

+0

看起來像netsuite堆棧交換從未發生過。 – drewish 2015-05-20 00:12:19

+0

正確,只需使用此網站和「netsuite」標記...鏈接已移除 – Vincent 2015-05-21 01:19:43

1

是的,你可以做到這一點使用計劃腳本,並將其安排爲你的願望。 沒有特殊的API函數來編輯現有文件,您可以獲取現有文件的詳細信息並創建具有相同詳細信息的新文件,但僅更改數據字段並刪除舊文件。

var start = function(request, response) 
{ 
    var fileId = "107524";//get the existing file id 
    var file = nlapiLoadFile(fileId); 
    var data = file.getValue(); 
    var name = file.getName(); 
    var folderId = file.getFolder(); 
    var fileType = file.getType(); 
    nlapiDeleteFile(fileId);//delete the older file 

    data += "this is the appended data";//change the data 
    var newFile = nlapiCreateFile(name, fileType, data);//create a new file with the same details 
    newFile.setFolder(folderId); 
    nlapiSubmitFile(newFile);//submit it 
} 
相關問題