Acumatica API - 删除销售订单行

时间:2015-12-03 03:20:22

标签: api lines erp acumatica sales

我想按给定的OrderNbr删除所有销售订单行,然后使用相同的销售订单号插入新的销售订单行。 这仅适用于“打开”或“信用保留”状态的销售订单以及订货行当然没有发货。

如何获取行数并通过每行删除呢? 我如何使用SO301000.DocumentDetails.ServiceCommands.DeleteRow?

2 个答案:

答案 0 :(得分:1)

我认为你应该使用类似的东西:



var commands = new List<Command>
{
    new Value { LinkedCommand = SO301000.OrderSummary.OrderType, Value = "SO"},
    new Value { LinkedCommand = SO301000.OrderSummary.OrderNbr, Value = "XXXXXX"},

    SO301000.DocumentDetails.ServiceCommands.RowNumber,
    SO301000.DocumentDetails.OrderType,
    SO301000.DocumentDetails.OrderNbr,
    SO301000.DocumentDetails.LineNbr,
    SO301000.DocumentDetails.InventoryID,
    SO301000.DocumentDetails.Quantity,
};

var content = context.SO301000Submit(commands.ToArray());
&#13;
&#13;
&#13;

然后循环播放&#34;内容&#34;现在是销售订单中所有行的列表,并执行 SO301000.DocumentDetails.ServiceCommands.DeleteRow 以清除它们。

答案 1 :(得分:1)

这也适用于报价或任何营销文档。

以下是供进一步参考的代码:

试             {                 apitest.Screen context = new apitest.Screen();                 context.CookieContainer = new System.Net.CookieContainer();

            context.Url = "http://localhost/Acumatica52v1865/Soap/APITEST.asmx";

            LoginResult lresult = context.Login("admin", "123");

            var SO301000 = context.SO301000GetSchema();
            context.SO301000Clear();

            var commands = new List<Command>
            {
                new Value { LinkedCommand = SO301000.OrderSummary.OrderType, Value = "SO"},
                new Value { LinkedCommand = SO301000.OrderSummary.OrderNbr, Value = "000179"},

                SO301000.DocumentDetails.ServiceCommands.RowNumber,
                SO301000.DocumentDetails.OrderType,
                SO301000.DocumentDetails.OrderNbr,
                SO301000.DocumentDetails.LineNbr,
                SO301000.DocumentDetails.InventoryID,
                SO301000.DocumentDetails.Quantity,
            };

            var content = context.SO301000Submit(commands.ToArray());

            List<Command> cmds = new List<Command>();
            cmds.Add(new Value { LinkedCommand = SO301000.OrderSummary.OrderType, Value = "SO" });
            cmds.Add(new Value { LinkedCommand = SO301000.OrderSummary.OrderNbr, Value = "000179" });

            //Remove all row,
            foreach (var item in content)
            {
                cmds.AddRange(new List<Command>
                        {
                            SO301000.DocumentDetails.ServiceCommands.DeleteRow
                        });
            }

            cmds.Add(SO301000.DocumentDetails.ServiceCommands.NewRow);
            cmds.Add(new Value { Value = "301CMPST01", LinkedCommand = SO301000.DocumentDetails.InventoryID, Commit = true });
            cmds.Add(new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity, Commit = true });
            cmds.Add(new Value { Value = "110", LinkedCommand = SO301000.DocumentDetails.UnitPrice });

            cmds.Add(SO301000.Actions.Save);
            context.SO301000Submit(cmds.ToArray());
        }
        catch (Exception ex)
        {
            throw ex;
        }