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

How To Retrieve An Attribute Field In StockItems In Acumatica API?

我想知道是否可以在 Web 服务中检索特定属性 API? 我在导出时尝试了 IN202500.AttributesAttributes.Value,但它列出了库存的所有属性。我还注意到属性在 table 中保存为清单 table 中的 [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字段是一个空字符串。 谢谢, G

此示例展示了如何添加项目并设置属性和图像:

        byte[] filedata;
        using (System.IO.FileStream file = System.IO.File.Open(@"C:.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
        });

您可以利用添加到屏幕主视图的动态字段来检索特定的属性值。这些字段不会出现在 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 属性)。结果变量包含一个二维数组,如果您需要帮助从数组中获取结果,请告诉我。