I’m trying to create an opportunity using code.But somehow there is an error saying PX.Data.PXOuterException: 'Error: Inserting 'Opportunity Address' record raised at least one error. Please review the errors.'
. I tried for hours to solve this issue. Some help would be appreciated. The error message also says that the CountryID cannot be empty. But its not empty.
var graph = PXGraph.CreateInstance<OpportunityMaint>();
var opp = new CROpportunity();
var addrs = new CRAddress();
var bAddrs = new CRBillingAddress();
var sAddrs = new CRShippingAddress();
addrs.CountryID = "US";
bAddrs.CountryID = "US";
sAddrs.CountryID = "US";
bAddrs.OverrideAddress = true;
sAddrs.OverrideAddress = true;
var addr1 = graph.Opportunity_Address.Insert(addrs);
var addr2 = graph.Billing_Address.Insert(bAddrs);
var addr3 = graph.Shipping_Address.Insert(sAddrs);
graph.Save.Press();
opp = graph.Opportunity.Insert(opp);
opp.Status = "N";
opp.ClassID = "PRODUCT";
opp.StageID = "L";
opp.CloseDate = DateTime.Now.Date;
opp.Subject = "This is the fake subject";
opp.OpportunityAddressID = addr1.AddressID;
opp.BillAddressID = addr2.AddressID;
opp.ShipAddressID = addr3.AddressID;
graph.Save.Press();