创建采购订单收货(退货)抛出错误“处理字段时发生错误供应商参考值<>已被使用”

时间:2017-08-14 03:09:43

标签: acumatica

我正在使用基于屏幕的API并且它正在运行,最近开始收到错误,说明该文档中存在供应商参考。

我注意到webservice调用以某种方式尝试创建文档2次,并在第二次出现此错误。

以下是代码,我无法弄清楚出了什么问题。

         PO302000Content ReturnSchema;    
        ReturnSchema = context.PO302000GetSchema();

         context.PO302000Submit(new Command[] { ReturnSchema.Actions.Insert });
        //HEADER
          AcumaticaInterface.apitest.Command[] Document = new AcumaticaInterface.apitest.Command[]
                    {
                        new Value
                        {
                            Value = interfaceStatus.Doc1Type,
                            LinkedCommand = ReturnSchema.DocumentSummary.Type
                        },
                        ReturnSchema.Actions.Insert,
                         new Value
                        {
                            Value = BPCode,
                            LinkedCommand = ReturnSchema.DocumentSummary.Vendor,
                            Commit = true
                        },
                         new Value
                        {
                            Value = BPRefNbr ,
                            LinkedCommand = ReturnSchema.DocumentSummary.VendorRef
                        },
                         new Value
                        {
                            Value = PostDate.HasValue ? ((DateTime)PostDate.Value).ToLongDateString() : "",
                            LinkedCommand = ReturnSchema.DocumentSummary.Date
                        },              
                         new Value
                        {
                            Value = Comments,
                            LinkedCommand = ReturnSchema.DocumentSummary.NoteText
                        },
                        new Value
                        {
                            Value = "TEST VALUE",
                            LinkedCommand = ReturnSchema.DocumentSummary.VendorRef
                        }
                    };
        context.PO302000Submit(Document);

    //LINE
         AcumaticaInterface.apitest.Command[] Docline = new AcumaticaInterface.apitest.Command[]
                                    {
                                     ReturnSchema.DocumentDetails.ServiceCommands.NewRow,
                                    new Value 
                                    {
                                        Value = line.ItemID, 
                                        LinkedCommand = ReturnSchema.DocumentDetails.InventoryID 
                                    },

                                     new Value 
                                    {
                                        Value = OutletCode, 
                                        LinkedCommand = ReturnSchema.DocumentDetails.Warehouse 
                                    },
                                     new Value 
                                    {
                                        Value = line.Uom, 
                                        LinkedCommand = ReturnSchema.DocumentDetails.UOM ,                               
                                    }, 
                                    new Value 
                                    {
                                        Value = line.Qty.ToString(), 
                                        LinkedCommand = ReturnSchema.DocumentDetails.ReceiptQty ,
                                        Commit = true
                                    },                                                     
                                      new Value 
                                    {
                                        Value = line.Price.ToString(), 
                                        LinkedCommand = ReturnSchema.DocumentDetails.UnitCost,
                                        Commit = true
                                    },
                                      new Value 
                                    {
                                        Value = line.DiscPct.ToString(), 
                                        LinkedCommand = ReturnSchema.DocumentDetails.DiscountPercent,
                                        Commit = true
                                    },
                                     new Value 
                                    {
                                        Value = line.LineRemarks, 
                                        LinkedCommand = ReturnSchema.DocumentDetails.NoteText ,       
                                        Commit = true
                                    }
                                    };
                        Document = Document.Concat(Docline).ToArray();

         //save
                    AcumaticaInterface.apitest.Command[] save = new AcumaticaInterface.apitest.Command[] {
                                ReturnSchema.Actions.Save,
         ReturnSchema.DocumentSummary.Type,
                        ReturnSchema.DocumentSummary.ReceiptNbr
                            };
Document = Document.Concat(save).ToArray();
        //EXCEPTION HERE
         var ReturnDoc = context.PO302000Submit(Document)[0];

1 个答案:

答案 0 :(得分:0)

找到解决方案

提交标题数据后,我清除了命令。但奇怪的是它之前有效。

 context.PO302000Submit(Document);
 Document = new Command[] { };
相关问题