Solved

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

  • 9 December 2020
  • 2 replies
  • 65 views

Userlevel 1

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.

 
icon

Best answer by Naveen B 10 December 2020, 14:26

@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

2 replies

Userlevel 4
Badge +1

@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();
}
Userlevel 1

Thank you @naveenb74 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved