如何在Acumatica API中的StockItems中检索属性字段?

时间:2015-01-22 01:02:18

标签: acumatica

我想知道是否可以在Web Service API中检索特定属性? 我在导出时尝试IN202500.AttributesAttributes.Value,但列出了广告资源的所有属性。我还注意到属性作为Inventory表中的[AttributeName] _Attributes保存在表中,有没有办法检索这个?

这是我正在使用的代码(期望它将检索属性)

IN202500Content IN202500 = context.IN202500GetSchema();
context.IN202500Clear();

Command[] oCmd = new Command[] {
                      IN202500.StockItemSummary.ServiceCommands.EveryInventoryID,
                      IN202500.StockItemSummary.InventoryID,
                      IN202500.StockItemSummary.Description, 
                      IN202500.StockItemSummary.ItemStatus, 
                      IN202500.GeneralSettingsItemDefaults.ItemClass, 
                      IN202500.GeneralSettingsItemDefaults.LotSerialClass,
                      new Field  {  
                          ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName,
                          FieldName = "BARCODE_Attributes"}, 
                      new Field  {  
                          ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName, 
                          FieldName = "DfltReceiptLocationID"},   
                      new Field  {  
                          ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName, 
                          FieldName = "LastModifiedDateTime"}   
                      };

Filter[] oFilter = new Filter[] {
                      new Filter 
                      {
                          Field = new Field {
                              ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName,
                              FieldName = "LastModifiedDateTime"},
                          Condition = FilterCondition.Greater,
                          Value = SyncDate
                       }
                    };

String[][] sReturn = context.IN202500Export(oCmd, oFilter, 0, true, false);

但返回的Attribute字段是一个空字符串。 谢谢, ģ

2 个答案:

答案 0 :(得分:1)

您可以利用添加到屏幕主视图的动态字段来检索特定的属性值。这些字段不会显示在WSDL架构中,因此您必须创建一个Field对象并将其传递给Export函数。

我通过显示本机对象/本机字段名称列从导出方案中查找字段名称和对象名称。结果导出调用如下所示:

        var result = screen.Export(new IN202500.Command[] { 
            new IN202500.Value() { LinkedCommand = schema.StockItemSummary.InventoryID, Value = "Z730P00073"},
            schema.StockItemSummary.InventoryID,
            schema.StockItemSummary.Description,
            new IN202500.Field { FieldName = "COLOR_Attributes", ObjectName = "Item"},
            new IN202500.Field { FieldName = "HWMAN_Attributes", ObjectName = "Item"},
        }, null, 0, true, true);

此代码将检索特定库存项目(Z730P00073)的两个属性值(COLOR和HWMAN属性)。结果变量包含一个二维数组,如果您需要帮助从数组中获取结果,请告诉我。

答案 1 :(得分:0)

此示例显示如何添加项目以及设置属性和图像:

        byte[] filedata;
        using (System.IO.FileStream file = System.IO.File.Open(@"C:\1.jpg", System.IO.FileMode.Open))
        {
            filedata = new byte[file.Length];
            file.Read(filedata, 0, filedata.Length);
        }

        Random rnd = new Random();  
        string inventoryID = "CPU0000" + rnd.Next(100).ToString();
        context.IN202500Clear();            
        IN202500result = context.IN202500Submit(
            new Command[] 
            {
                IN202500.Actions.Insert,
                new Value { Value = inventoryID, LinkedCommand = IN202500.StockItemSummary.InventoryID },
                new Value { Value = inventoryID, LinkedCommand = IN202500.StockItemSummary.Description },
                new Value { Value = "CPU", LinkedCommand = IN202500.GeneralSettingsItemDefaults.ItemClass, Commit = true },
                new Value { Value = "TAXABLE", LinkedCommand = IN202500.GeneralSettingsItemDefaults.TaxCategory, Commit = true },                    
                //attributes - pairs 
                new Value { Value = "FREQUENCY", LinkedCommand = IN202500.AttributesAttributes.Attribute },
                new Value { Value = "1400", LinkedCommand = IN202500.AttributesAttributes.Value, Commit = true },
                new Value { Value = "CORE", LinkedCommand = IN202500.AttributesAttributes.Attribute },
                new Value { Value = "2 CORES", LinkedCommand = IN202500.AttributesAttributes.Value, Commit = true },
                new Value { Value = "INTGRAPH", LinkedCommand = IN202500.AttributesAttributes.Attribute },
                new Value { Value = "True", LinkedCommand = IN202500.AttributesAttributes.Value, Commit = true },
                //image
                new Value { Value = Convert.ToBase64String(filedata), FieldName = "1.jpg", LinkedCommand = IN202500.StockItemSummary.ServiceCommands.Attachment }, //uploads
                new Value { Value = "1.jpg", LinkedCommand = IN202500.Attributes.ImageUrl }, //sets as an item picture
                IN202500.Actions.Save,
                //return the result
                IN202500.StockItemSummary.InventoryID
        });