Skip to main content
Solved

Error custom project in 2020R1 "Revision code cannot be empty" after migration

  • December 9, 2020
  • 2 replies
  • 721 views

Hollo,

I have a custom project that runs fine on the 2019R2 version. I updated to 2020R1 and I imported the custom project. I encountered this error : β€œThe insertion of the record 'Billing address' generated at least one error. Please correct the errors. Error: 'Revision code' cannot be empty.”

 

Best regards.

 

Best answer by Naveen Boga

@mohamed1walha,

Below is the sample to create the Sales Order through code. Hope this help!!

 

SOOrder newOrder = new SOOrder();
            newOrder.OrderType = "SO";
            newOrder = SOGraph.Document.Insert(newOrder);
            newOrder = PXCache<SOOrder>.CreateCopy(SOGraph.Document.Search<SOOrder.orderNbr>(newOrder.OrderNbr));
            newOrder = PXCache<SOOrder>.CreateCopy(SOGraph.Document.Update(newOrder));

            newOrder.CustomerID = BaseGraph.Document.Current.CustomerID;
            newOrder.CustomerLocationID = BaseGraph.Document.Current.CustomerLocationID;
            newOrder.OrderDesc = "CM Order Created for " + objSOOrder.OrderType + " :" + objSOOrder.OrderNbr;

            newOrder.TaxZoneID = BaseGraph.Document.Current.TaxZoneID;
            newOrder.GetExtension<SOOrderAMIOEExt>().UsrKNAMIShipTermsID = null;
            SOGraph.Document.Current = newOrder;
            SOGraph.Document.Current = SOGraph.Document.Update(SOGraph.Document.Current);

            SOGraph.Document.Current.ShipAddressID = BaseGraph.Document.Current.ShipAddressID;
            SOGraph.Document.Current.ShipContactID = BaseGraph.Document.Current.ShipContactID;
            SOGraph.Document.Current.BillAddressID = BaseGraph.Document.Current.BillAddressID;
            SOGraph.Document.Current.BillContactID = BaseGraph.Document.Current.BillContactID;

            SOGraph.Document.Current = SOGraph.Document.Update(SOGraph.Document.Current);

            foreach (SOLine objSOLine in BaseGraph.Transactions.Select().FirstTableItems.ToList().Where(x => x.GetExtension<SOLineAMIOEExt>().UsrKNAMIOERefundQty > 0))
            {
                SOLineAMIOEExt lineExt = objSOLine.GetExtension<SOLineAMIOEExt>();

                SOLine newitem = (SOLine)SOGraph.Transactions.Cache.Insert();
                newitem.InventoryID = objSOLine.InventoryID;
                SOGraph.Transactions.Cache.Update(newitem);
                newitem.Qty = lineExt.UsrKNAMIOERefundQty;
                newitem.ReasonCode = lineExt.UsrKNAMIOEReasonCode;
                newitem.ManualPrice = true;
                newitem.SiteID = objSOLine.SiteID;
                newitem.CuryUnitPrice = objSOLine.CuryUnitPrice;
                SOGraph.Transactions.Cache.Update(newitem);

            }

            if (shipRefundFilter.RefundFreightAmount > 0)
            {
                InventoryItem objItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.
                                        Select(SOGraph, SOGraph.sosetup.Current.GetExtension<SOSetupAMIOEExt>().UsrKNAMIFreightChrg);
                if (objItem != null)
                {
                    SOLine newitem = (SOLine)SOGraph.Transactions.Cache.Insert();
                    newitem.InventoryID = objItem.InventoryID;
                    SOGraph.Transactions.Cache.Update(newitem);
                    newitem.Qty = 1;
                    newitem.ReasonCode = "DAMAGED";
                    newitem.ManualPrice = true;
                    newitem.SiteID = objItem.DfltSiteID;
                    newitem.CuryUnitPrice = shipRefundFilter.RefundFreightAmount;
                    SOGraph.Transactions.Cache.Update(newitem);
                }
            }


            if (shipRefundFilter.RefundDiscountAmount > 0)
            {
                InventoryItem objDiscITem = PXSelect<InventoryItem, Where<InventoryItem.inventoryCD, Equal<Required<InventoryItem.inventoryCD>>>>.Select(SOGraph, "ORDERDISCOUNT");
                if (objDiscITem != null)
                {
                    SOLine newitem = (SOLine)SOGraph.Transactions.Cache.Insert();
                    newitem.InventoryID = objDiscITem.InventoryID;
                    SOGraph.Transactions.Cache.Update(newitem);
                    newitem.Qty = 1;
                    newitem.ReasonCode = "DAMAGED";
                    newitem.ManualPrice = true;
                    newitem.SiteID = objDiscITem.DfltSiteID;
                    newitem.CuryUnitPrice = -(Math.Abs(Convert.ToDecimal(shipRefundFilter.RefundDiscountAmount)));
                    SOGraph.Transactions.Cache.Update(newitem);
                }
            }


            SOGraph.Save.Press();
        }
View original
Did this topic help you find an answer to your question?

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3410 replies
  • Answer
  • December 10, 2020

@mohamed1walha,

Below is the sample to create the Sales Order through code. Hope this help!!

 

SOOrder newOrder = new SOOrder();
            newOrder.OrderType = "SO";
            newOrder = SOGraph.Document.Insert(newOrder);
            newOrder = PXCache<SOOrder>.CreateCopy(SOGraph.Document.Search<SOOrder.orderNbr>(newOrder.OrderNbr));
            newOrder = PXCache<SOOrder>.CreateCopy(SOGraph.Document.Update(newOrder));

            newOrder.CustomerID = BaseGraph.Document.Current.CustomerID;
            newOrder.CustomerLocationID = BaseGraph.Document.Current.CustomerLocationID;
            newOrder.OrderDesc = "CM Order Created for " + objSOOrder.OrderType + " :" + objSOOrder.OrderNbr;

            newOrder.TaxZoneID = BaseGraph.Document.Current.TaxZoneID;
            newOrder.GetExtension<SOOrderAMIOEExt>().UsrKNAMIShipTermsID = null;
            SOGraph.Document.Current = newOrder;
            SOGraph.Document.Current = SOGraph.Document.Update(SOGraph.Document.Current);

            SOGraph.Document.Current.ShipAddressID = BaseGraph.Document.Current.ShipAddressID;
            SOGraph.Document.Current.ShipContactID = BaseGraph.Document.Current.ShipContactID;
            SOGraph.Document.Current.BillAddressID = BaseGraph.Document.Current.BillAddressID;
            SOGraph.Document.Current.BillContactID = BaseGraph.Document.Current.BillContactID;

            SOGraph.Document.Current = SOGraph.Document.Update(SOGraph.Document.Current);

            foreach (SOLine objSOLine in BaseGraph.Transactions.Select().FirstTableItems.ToList().Where(x => x.GetExtension<SOLineAMIOEExt>().UsrKNAMIOERefundQty > 0))
            {
                SOLineAMIOEExt lineExt = objSOLine.GetExtension<SOLineAMIOEExt>();

                SOLine newitem = (SOLine)SOGraph.Transactions.Cache.Insert();
                newitem.InventoryID = objSOLine.InventoryID;
                SOGraph.Transactions.Cache.Update(newitem);
                newitem.Qty = lineExt.UsrKNAMIOERefundQty;
                newitem.ReasonCode = lineExt.UsrKNAMIOEReasonCode;
                newitem.ManualPrice = true;
                newitem.SiteID = objSOLine.SiteID;
                newitem.CuryUnitPrice = objSOLine.CuryUnitPrice;
                SOGraph.Transactions.Cache.Update(newitem);

            }

            if (shipRefundFilter.RefundFreightAmount > 0)
            {
                InventoryItem objItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.
                                        Select(SOGraph, SOGraph.sosetup.Current.GetExtension<SOSetupAMIOEExt>().UsrKNAMIFreightChrg);
                if (objItem != null)
                {
                    SOLine newitem = (SOLine)SOGraph.Transactions.Cache.Insert();
                    newitem.InventoryID = objItem.InventoryID;
                    SOGraph.Transactions.Cache.Update(newitem);
                    newitem.Qty = 1;
                    newitem.ReasonCode = "DAMAGED";
                    newitem.ManualPrice = true;
                    newitem.SiteID = objItem.DfltSiteID;
                    newitem.CuryUnitPrice = shipRefundFilter.RefundFreightAmount;
                    SOGraph.Transactions.Cache.Update(newitem);
                }
            }


            if (shipRefundFilter.RefundDiscountAmount > 0)
            {
                InventoryItem objDiscITem = PXSelect<InventoryItem, Where<InventoryItem.inventoryCD, Equal<Required<InventoryItem.inventoryCD>>>>.Select(SOGraph, "ORDERDISCOUNT");
                if (objDiscITem != null)
                {
                    SOLine newitem = (SOLine)SOGraph.Transactions.Cache.Insert();
                    newitem.InventoryID = objDiscITem.InventoryID;
                    SOGraph.Transactions.Cache.Update(newitem);
                    newitem.Qty = 1;
                    newitem.ReasonCode = "DAMAGED";
                    newitem.ManualPrice = true;
                    newitem.SiteID = objDiscITem.DfltSiteID;
                    newitem.CuryUnitPrice = -(Math.Abs(Convert.ToDecimal(shipRefundFilter.RefundDiscountAmount)));
                    SOGraph.Transactions.Cache.Update(newitem);
                }
            }


            SOGraph.Save.Press();
        }

  • Author
  • Jr Varsity II
  • 22 replies
  • December 10, 2020

Thank you @naveenb74 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings