Screen based API creation of PO receipt from POLine issue

自作多情 提交于 2019-12-25 05:51:42

问题


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
};


来源:https://stackoverflow.com/questions/42271116/screen-based-api-creation-of-po-receipt-from-poline-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!