2014-10-03 90 views
0

我正在使用Acumatica 4.2,並通過另一個系統的API插入銷售訂單。 該請求已經出現,可以爲銷售訂單添加備註,並且我沒有看到有關如何執行此操作的任何有用信息。提前致謝。這裏是我使用Acumatica WebAPI插入SalesOrder的代碼。它的功能非常好。如何在使用api插入銷售訂單時將註釋插入銷售訂單註釋中?

在銷售訂單屏幕上,右上方還有一個備註指示器,可將註釋添加到銷售訂單中。我將如何使用acumatica web api添加註釋?或者我只是使用返回的SONumber並使用SONumber作爲參考插入註釋。我以前不必處理筆記。

try 
    { 
     cmds.AddRange(
      new SO301000_509.Command[] 
     { 
      so301000.Actions.Insert, 
        new SO301000_509.Value { Value = "SO", LinkedCommand = so301000.OrderSummary.OrderType }, 
        new SO301000_509.Value { Value = "='new'", LinkedCommand = so301000.OrderSummary.OrderNbr }, 
        new SO301000_509.Value { Value = dealerOrder.accountCode, LinkedCommand = so301000.OrderSummary.Customer }, 
        //new SO301000_509.Value { Value = ((DateTime)dealerOrder.orderDateTime).ToShortDateString(), LinkedCommand = so301000.OrderSummary.Date }, 
        new SO301000_509.Value { Value = (dealerOrder.orderDateTime), LinkedCommand = so301000.OrderSummary.Date }, 
        new SO301000_509.Value { Value = "Hubsoft Order Nbr: " + dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.Description }, 
        new SO301000_509.Value { Value = dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerRef }, 
        new SO301000_509.Value { Value = "HS-" + dealerOrder.purchaseOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerOrder }, 
        //new SO301000_509.Value { Value = dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.ControlTotal }, 
     } 
     ); 
     //create the sales order lines in loop 
     for (var idx = 0; idx < SalesOrderLine.Length; idx++) 
     { 
      cmds.AddRange(
       new SO301000_509.Command[] 
      { 
       so301000.DocumentDetails.ServiceCommands.NewRow, 
        //simple line adding 
        so301000.DocumentDetails.ServiceCommands.NewRow, 
        new SO301000_509.Value { Value = SalesOrderLine[idx].inventoryCD, LinkedCommand = so301000.DocumentDetails.InventoryID }, 
        new SO301000_509.Value { Value = SalesOrderLine[idx].UOM, LinkedCommand = so301000.DocumentDetails.UOM }, 
        new SO301000_509.Value { Value = SalesOrderLine[idx].Qty, LinkedCommand = so301000.DocumentDetails.Quantity }, 
        new SO301000_509.Value { Value = "MAIN", LinkedCommand = so301000.DocumentDetails.Warehouse},       
        new SO301000_509.Value { Value = SalesOrderLine[idx].UnitPrice, LinkedCommand = so301000.DocumentDetails.UnitPrice, Commit = true }, 
      } 
      ); 
     } 
     cmds.Add(so301000.Actions.Save);            //save all 
     cmds.Add(so301000.OrderSummary.OrderNbr);          //return Order # 

     SO301000_509.Content[] SO301000Content = context.Submit(cmds.ToArray());   //submit 
     PXTrace.WriteInformation(SO301000Content[0].OrderSummary.OrderNbr.Value); 
     acumaticaSONbr = SO301000Content[0].OrderSummary.OrderNbr.Value; 
    } 
    catch (Exception ex) 
    { 
     PXTrace.WriteError("Error adding Sales Order - " + ex.Message); 
    } 
    return acumaticaSONbr; 
+0

你提的問題是非常低質量的..你可以添加更多的細節? – Miki 2014-10-03 23:30:33

+0

我理解這個問題,但是提供一個代碼示例顯示問題以及您已經嘗試過的內容有助於提高問題的質量。 – Gabriel 2014-10-06 13:06:40

+0

@Gabriel代碼和說明已更新 – xDJR1875 2014-10-06 17:02:52

回答

1
 Content SO301000 = context.GetSchema(); 
     context.Clear(); 
     Content[] result = context.Submit(
      new Command[]{ 
       new Value { Value = "000586", LinkedCommand = SO301000.OrderSummary.OrderNbr, Commit = true }, 
       new Value { Value = "NoteText", LinkedCommand = SO301000.OrderSummary.NoteText, Commit = true }, 
       SO301000.Actions.Save 
      } 
     ); 
+0

我已添加此代碼,現在可以插入銷售訂單的備註。謝謝! – xDJR1875 2014-10-07 19:02:58

0

這樣做的另一種方式是銷售訂單本身的第一個插件內。 由acumember發佈的示例需要第二次調用API。 由於我們一次插入許多銷售訂單,我們想要限制我們的呼叫。 所以下面的工作也只需要一個電話。

感謝

 try 
     { 
      cmds.AddRange(
       new SO301000_509.Command[] 
      { 
       so301000.Actions.Insert, 
         new SO301000_509.Value { Value = "SO", LinkedCommand = so301000.OrderSummary.OrderType }, 
         new SO301000_509.Value { Value = "='new'", LinkedCommand = so301000.OrderSummary.OrderNbr }, 
         new SO301000_509.Value { Value = dealerOrder.accountCode, LinkedCommand = so301000.OrderSummary.Customer }, 
         new SO301000_509.Value { Value = (dealerOrder.orderDateTime), LinkedCommand = so301000.OrderSummary.Date }, 
         new SO301000_509.Value { Value = "Hubsoft Order Nbr: " + dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.Description }, 
         new SO301000_509.Value { Value = dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerRef }, 
         new SO301000_509.Value { Value = "HS-" + dealerOrder.purchaseOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerOrder }, 

         **new SO301000_509.Value { Value = dealerOrder.notes, LinkedCommand = so301000.OrderSummary.NoteText},** 

         new SO301000_509.Value { Value = "1", LinkedCommand = so301000.ShippingSettingsShipToInfo.OverrideAddress }, 
         new SO301000_509.Value { Value = shipStreet1, LinkedCommand = so301000.ShippingSettingsShipToInfo.AddressLine1 }, 
         new SO301000_509.Value { Value = shipStreet2, LinkedCommand = so301000.ShippingSettingsShipToInfo.AddressLine2 }, 
         new SO301000_509.Value { Value = shipCity, LinkedCommand = so301000.ShippingSettingsShipToInfo.City }, 
         new SO301000_509.Value { Value = shipState, LinkedCommand = so301000.ShippingSettingsShipToInfo.State }, 
         new SO301000_509.Value { Value = shipCountry, LinkedCommand = so301000.ShippingSettingsShipToInfo.Country }, 
         new SO301000_509.Value { Value = shipPostal, LinkedCommand = so301000.ShippingSettingsShipToInfo.PostalCode }, 
      } 
      ); 
      //create the sales order lines in loop 
      for (var idx = 0; idx < SalesOrderLine.Length; idx++) 
      { 
       cmds.AddRange(
        new SO301000_509.Command[] 
       { 
        so301000.DocumentDetails.ServiceCommands.NewRow, 
         //simple line adding 
         so301000.DocumentDetails.ServiceCommands.NewRow, 
         new SO301000_509.Value { Value = SalesOrderLine[idx].inventoryCD, LinkedCommand = so301000.DocumentDetails.InventoryID }, 
         new SO301000_509.Value { Value = SalesOrderLine[idx].UOM, LinkedCommand = so301000.DocumentDetails.UOM }, 
         new SO301000_509.Value { Value = SalesOrderLine[idx].Qty, LinkedCommand = so301000.DocumentDetails.Quantity }, 
         new SO301000_509.Value { Value = "MAIN", LinkedCommand = so301000.DocumentDetails.Warehouse},       
         new SO301000_509.Value { Value = SalesOrderLine[idx].UnitPrice, LinkedCommand = so301000.DocumentDetails.UnitPrice, Commit = true }, 
       } 
       ); 
      } 
      cmds.Add(so301000.Actions.Save);             //save all 
      cmds.Add(so301000.OrderSummary.OrderNbr);           //return Order #