2015-09-17 61 views

回答

3

在SuiteScript,你可以加載你想檢查記錄的一個實例,然後調用其getAllFields方法:

var record = nlapiLoadRecord('customrecord_summaryinvoice', 'anyInternalIdHere'); 
var fieldNames = record.getAllFields(); 

// Do whatever you need to with fieldNames... 

不幸的是,我不熟悉的Web服務足以推薦的在那裏接近。

+0

我想有一個跟進的問題 我)我將如何得到,如果所有的自定義記錄列表,以及 II)記錄類型不存在,我們不能提取出我們首先需要創建記錄的字段 我們是否有解決上述2個問題的方法? – Anshul

+1

不幸的是NetSuite的元數據發現不足。我不知道通過編程獲取所有自定義記錄的列表的好方法。第二個問題的一個選擇是手動創建該類型的單個記錄,然後將其標記爲非活動狀態。您仍然可以使用'nlapiLoadRecord'加載非活動記錄,但它不會顯示在普通搜索結果或其他列表中。 – erictgrubaugh

+0

感謝egrubaugh360 會編寫一個爬行程序來提取數據並獲取元數據/自定義記錄列表,這是一個很好的解決方案嗎? – Anshul

0

在SuiteTalk中有一個API調用,您可以調用它來返回所有自定義記錄的元數據(scriptId,internalId)。

我使用C#:

public Dictionary<string, string> GetCustomization() 
{ 

    Dictionary<string, string> customRecords = new Dictionary<string, string>(); 

    // gets metadata for all custom records. 
    CustomizationType ct = new CustomizationType() { 
     getCustomizationType = GetCustomizationType.customRecordType, 
     getCustomizationTypeSpecified = true 
    }; 

    GetCustomizationIdResult cr = _myNetSuiteWebReference.getCustomizationId(ct, false); 

    foreach (CustomizationRef re in cr.customizationRefList) 
    { 
     customRecords.Add(re.scriptId, re.internalId); 
    } 

    return customRecords; 
} 

如果您已經下載使用Web服務的記錄,你可以使用反射來獲取對象的屬性。

我將使用一個銷售訂單記錄只是一個例子:

RecordRef rr = new RecordRef(); 
rr.internalId = "123456789"; 
rr.typeSpecified = true; 
rr.type = RecordType.salesOrder; 

ReadResponse readr = Get(rr); 
// cast so a sales order object. 
SalesOrder so = (SalesOrder)readr.record; 

so.getType().getProperties(); // returns an array of PropertyInfo. 
foreach(System.Reflection.PropertyInfo pi in so.getType().getProperties()) 
{ 
    Console.WriteLine(pi.Name); 
}