Screen based API creation of PO receipt from POLin

2019-09-12 04:21发布

问题:

We are trying to add PO lines to the receipt document using 'ADD PO LINE' smartpanel. Below is the code, but it always chooses the first 2 lines instead of the keys specified in the command.

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

We are trying to select the lines of order Nbr '000014' [Line Nbr(1,2)], but the lines added are of Order Nbr '000012' [Line Nbr(1,2)]. Please assist.

回答1:

The solution is to clear LinkedCommand set by default for the AddPurchaseOrderLine.Selected field:

receiptSchema.AddPurchaseOrderLine.Selected.LinkedCommand = null;

Below is the complete SOAP request, that allows to locate and select records on the Add Purchase Order Line popup via the Screen-Based 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
};


标签: acumatica