从POLine问题创建PO收据的基于屏幕的API

时间:2017-02-16 10:22:58

标签: acumatica

我们正尝试使用“ADD PO LINE”智能面板将PO行添加到收据文档中。下面是代码,但它总是选择前两行而不是命令中指定的键。

//select lines from smart panel
foreach (POReceiptLine line in POReceiptlines.OrderBy(x => x.LineNum))
{
    AcumaticaInterface.apitest.Command[] Docline = new AcumaticaInterface.apitest.Command[]
                {                     
                    new Key
                    {
                        ObjectName = PORcptSchema.AddPurchaseOrderLine.OrderNbr.ObjectName,
                        FieldName = PORcptSchema.AddPurchaseOrderLine.OrderNbr.FieldName,
                        Value = "='" + line.BaseDocNum + "'",
                        Commit =true
                    },
                    new Key
                    {
                        ObjectName = PORcptSchema.AddPurchaseOrderLine.LineNbr.ObjectName,
                        FieldName = PORcptSchema.AddPurchaseOrderLine.LineNbr.FieldName,
                        Value = "='" + line.BaseLineNum + "'",
                        Commit =true
                    },              
                    new Value 
                    {
                        Value = "True", 
                        LinkedCommand = PORcptSchema.AddPurchaseOrderLine.Selected, 
                        Commit = true 
                    }  
                };
                Document = Document.Concat(Docline).ToArray();
            }

    // Add PO line and retrieve back the added lines.
    var addPOLine = new Command[]
                        {                             
                            addPOLineWithCommit,
                            ////get back the added lines in the grid
                            PORcptSchema.DocumentDetails.POOrderNbr,
                            PORcptSchema.DocumentDetails.POLineNbr
                        };
            Document = Document.Concat(addPOLine).ToArray();

            var receiptLines = context.PO302000Submit(Document);

enter image description here

我们正在尝试选择Nbr'000014'[Line Nbr(1,2)]的顺序行,但添加的行是Nbr'000012'[Line Nbr(1,2)]。请协助。

1 个答案:

答案 0 :(得分:0)

解决方案是清除AddPurchaseOrderLine.Selected字段默认设置的LinkedCommand:

receiptSchema.AddPurchaseOrderLine.Selected.LinkedCommand = null;

以下是完整的SOAP请求,允许通过基于屏幕的API在添加采购订单行弹出窗口中找到并选择记录:

Content receiptSchema = context.GetSchema();

receiptSchema.Actions.AddPOOrderLine.Commit = true;
receiptSchema.Actions.AddPOOrderLine2.Commit = true;

receiptSchema.AddPurchaseOrderLine.Selected.LinkedCommand = null;

var commands = new Command[]
{
    new Value
    {
        Value = "Receipt",
        LinkedCommand = receiptSchema.DocumentSummary.Type
    },

    new Value
    {
        Value = "PR000416",
        LinkedCommand = receiptSchema.DocumentSummary.ReceiptNbr
    },

    new Value
    {
        Value = "OK",
        LinkedCommand = receiptSchema.AddPurchaseOrderLine.ServiceCommands.DialogAnswer,
        Commit = true
    },

    receiptSchema.Actions.AddPOOrderLine,

    new Key
    {
        ObjectName = receiptSchema.AddPurchaseOrderLine.OrderNbr.ObjectName,
        FieldName = receiptSchema.AddPurchaseOrderLine.OrderNbr.FieldName,
        Value = "='PO000483'"
    },
    new Key
    {
        ObjectName = receiptSchema.AddPurchaseOrderLine.LineNbr.ObjectName,
        FieldName = receiptSchema.AddPurchaseOrderLine.LineNbr.FieldName,
        Value = "='1'"
    },
    new Value
    {
        Value = "True",
        LinkedCommand = receiptSchema.AddPurchaseOrderLine.Selected
    },

    new Key
    {
        ObjectName = receiptSchema.AddPurchaseOrderLine.OrderNbr.ObjectName,
        FieldName = receiptSchema.AddPurchaseOrderLine.OrderNbr.FieldName,
        Value = "='PO000483'"
    },
    new Key
    {
        ObjectName = receiptSchema.AddPurchaseOrderLine.LineNbr.ObjectName,
        FieldName = receiptSchema.AddPurchaseOrderLine.LineNbr.FieldName,
        Value = "='2'"
    },
    new Value
    {
        Value = "True",
        LinkedCommand = receiptSchema.AddPurchaseOrderLine.Selected
    },
    receiptSchema.Actions.AddPOOrderLine2,

    receiptSchema.Actions.Save
};