Acumatica API - 删除销售订单行
Acumatica API - Delete Sales Order Lines
我想删除给定 OrderNbr 的所有销售订单行,然后使用相同的销售订单号插入新的销售订单行。
这将仅针对处于 'Open' 或 'Credit Hold' 状态的销售订单完成,当然只要订单行尚未发货。
我怎样才能得到行数并遍历每一行然后删除?
如何使用 SO301000.DocumentDetails.ServiceCommands.DeleteRow?
我认为你应该使用类似的东西:
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());
然后遍历 "content",它现在是您销售订单中所有行的列表,并执行 SO301000.DocumentDetails.ServiceCommands.DeleteRow 以摆脱它们。
这也适用于报价单或任何营销文档。
以下代码供进一步参考:
try {
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;
}
我想删除给定 OrderNbr 的所有销售订单行,然后使用相同的销售订单号插入新的销售订单行。 这将仅针对处于 'Open' 或 'Credit Hold' 状态的销售订单完成,当然只要订单行尚未发货。
我怎样才能得到行数并遍历每一行然后删除? 如何使用 SO301000.DocumentDetails.ServiceCommands.DeleteRow?
我认为你应该使用类似的东西:
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());
然后遍历 "content",它现在是您销售订单中所有行的列表,并执行 SO301000.DocumentDetails.ServiceCommands.DeleteRow 以摆脱它们。
这也适用于报价单或任何营销文档。
以下代码供进一步参考:
try {
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;
}