2016-11-21 74 views
-6

我在嘗試此代碼以列出NetSuite中的文件櫃文件夾中的文件,但我只能列出文件。我需要列出文件夾中的文件夾與ID:28在指定文件夾中列出文件夾

的代碼我使用:

var folder = 28; 

var filters = new Array(); 
filters[0] = new nlobjSearchFilter('internalid', null, 'is', folder); 

var columns = new Array(); 
var filename = new nlobjSearchColumn('name', 'file'); 
var fileid = new nlobjSearchColumn('internalid', 'file'); 

columns[0] = filename; 
columns[1] = fileid; 

var searchResult = nlapiSearchRecord('folder', null , filters , columns); 
if(searchResult) { 
for (var i = 0 ; i < searchResult.length; i++) { 
    alert(searchResult[i].getValue(filename)+searchResult[i].getValue(fileid)); 
    }; 
}; 

結果:

warning File1.txt1938 11/22/2016 17:30:08.693 
warning File2.txt1636 11/22/2016 17:30:08.693 
warning File3.txt1939 11/22/2016 17:30:08.693 
warning File4.txt4601 11/22/2016 17:30:08.693 

這是正確的,但它只是上市文件,而不是文件夾?

謝謝!

+0

你真的應該掃描的文檔,至少。 – W3BGUY

回答

1

執行UserEvent BeforeLoad函數。所有文件都有一個父文件夾ID。

// pass in the internal id of the file's parent folder 
var folder = 415 // the folder ID we care about 

var filters = new Array(); 
filters[0] = new nlobjSearchFilter('internalid', null, 'is', folder); 

//file name and file internal ID 
var columns = new Array(); 
var filename = new nlobjSearchColumn('name', 'file'); 
var fileid = new nlobjSearchColumn('internalid', 'file'); 

columns[0] = filename; 
columns[1] = fileid; 

// perform the search and loop through the findings 
var searchResult = nlapiSearchRecord('folder', null , filters , columns); 
if(searchResult) { 
for (var i = 0 ; i < searchResult.length; i++) { 
    var f = searchResult[i]; 
    //do what you want with f here 
    }; 
}; 

信用:http://blog.prolecto.com/2014/01/09/get-netsuite-list-of-files-from-folder/

+0

我不想列出文件,我想列出文件夾中的文件夾 – eXtreme

+0

我閱讀文檔,我無法弄清楚:( – eXtreme

+0

我目前認爲系統有限制列出文件夾內的子文件夾?我對嗎? – eXtreme

1

我可以列出文件夾的子文件夾與此代碼:

var folder = 3232; 

var filters = new Array(); 
filters[0] = new nlobjSearchFilter('parent', null, 'is', folder); 

var columns = new Array(); 
var filename = new nlobjSearchColumn('name'); 
var fileid = new nlobjSearchColumn('internalid'); 

columns[0] = filename; 
columns[1] = fileid; 

var searchResult = nlapiSearchRecord('folder', null , filters , columns); 
if(searchResult) { 
for (var i = 0 ; i < searchResult.length; i++) { 
    alert(searchResult[i].getValue(filename)+searchResult[i].getValue(fileid)); 
    }; 
}; 
相關問題