0

我正在使用 Acumatica 4.2 并通过 api 从另一个系统插入销售订单。已提出向销售订单添加注释的请求,但我没有看到有关如何执行此操作的任何有用信息。提前致谢。这是我使用 Acumatica WebAPI 插入 SalesOrder 的代码。它的功能非常好。

在销售订单屏幕的右上角还有一个注释指示器,可以在其中将注释添加到销售订单中。我将如何使用 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;
4

2 回答 2

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
            }
        );
于 2014-10-07T09:38:06.380 回答
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 #
于 2014-10-10T17:14:10.417 回答