开发人员版本的Acumatica 2020R1在本地安装。加载了来自I-300培训的样本租户MyTenant的数据,并建立了WSDL连接。
DefaultSoapClient创建良好。
但是,尝试使用Getlist导出任何数据会导致错误:
using (Default.DefaultSoapClient soapClient =
new Default.DefaultSoapClient())
{
//Sign in to Acumatica ERP
soapClient.Login
(
"Admin",
"*",
"MyTenant",
"Yogifon",
null
);
try
{
//Retrieving the list of customers with contacts
//InitialDataRetrieval.RetrieveListOfCustomers(soapClient);
//Retrieving the list of stock items modified within the past day
// RetrievalOfDelta.ExportStockItems(soapClient);
RetrievalOfDelta.ExportItemClass(soapClient);
}
public static void ExportItemClass(DefaultSoapClient soapClient)
{
Console.WriteLine("Retrieving the list of item classes...");
ItemClass ItemClassToBeFound = new ItemClass
{
ReturnBehavior = ReturnBehavior.All,
};
Entity[] ItemClasses = soapClient.GetList(ItemClassToBeFound);
string lcItemType = "", lcValuationMethod = "";
int lnCustomFieldsCount;
using (StreamWriter file = new StreamWriter("ItemClass.csv"))
{
//Write the values for each item
foreach (ItemClass loItemClass in ItemClasses)
{
file.WriteLine(loItemClass.Note);
}
}
Acumatica实例通过使用DAC向库存项目添加自定义字段,以及向客户和库存项目添加多个属性进行了修改。
有趣的是,这段代码一直有效,直到出现问题为止。
这里怎么了?
谢谢。亚历山大
在请求中,您具有以下行:ReturnBehavior = ReturnBehavior.All
这意味着您尝试检索该对象的所有链接/详细信息实体。不幸的是,某些对象的优化程度不足以影响GetList方案中的查询性能。因此,您必须选择:
P.S。属性问题很可能会在下一版本的API端点中得到解决。
编辑:
获取代码示例:
public static void ExportItemClass(DefaultSoapClient soapClient)
{
Console.WriteLine("Retrieving the list of item classes...");
ItemClass ItemClassToBeFound = new ItemClass
{
ReturnBehavior = ReturnBehavior.Default //retrieve only default fields (without attributes and other linked/detailed entities)
};
Entity[] ItemClasses = soapClient.GetList(ItemClassToBeFound);
foreach(var entity in ItemClasses)
{
ItemClass itemClass= entity as ItemClass;
ItemClass.ReturnBehavior=ReturnBehavior.All;
// retrieve each ItemClass with all the details/linked entities individually
ItemClass retrievedItemCLass = soapClient.Get(itemClass);
}