2015-12-03 111 views
0

我想通過給定OrderNbr刪除所有銷售訂單行,然後使用相同的銷售訂單號插入新的銷售訂單行。 僅當銷售訂單處於「開放」或「信用保留」狀態並且當訂單行尚未發貨時纔會完成此操作。Acumatica API - 刪除銷售訂單行

如何獲取行數並通過每一個刪除呢? 如何使用SO301000.DocumentDetails.ServiceCommands.DeleteRow?

+0

你試過什麼嗎? – Hybridzz

回答

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());

然後通過「內容」,這是目前在銷售訂單中的所有行的列表,並做了SO301000循環。 DocumentDetails.ServiceCommands.DeleteRow擺脫它們。

+1

謝謝加文,這是如何完成的。 我們爲同一家公司工作很有趣。大聲笑 –

1

這也適用於行情或任何營銷文檔。

下面是進一步參考的代碼:

嘗試 { apitest.Screen上下文=新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; 
     } 
相關問題