In version 24_202_0026 which was upgraded from version 23_107_0022 I attempt to programmatically create a SO document. The Bill Address and Bill Contact handling code works with issues. I had the PX.Data.PXLockViolationException error on PressSave().
SOBillingAddress billAddress = docgraph.Billing_Address.Current = docgraph.Billing_Address.Select();
billAddress.OverrideAddress = true;
billAddress = docgraph.Billing_Address.Update(billAddress);
docgraph.Actions.PressSave();
Here I have fond a potential solution.
SOBillingAddress billAddress = docgraph.Billing_Address.Current = docgraph.Billing_Address.Update(new SOBillingAddress { OverrideAddress = true });
docgraph.Actions.PressSave();
Using the recommended code I get the PX.Data.PXOuterException: 'Error: Inserting 'Billing Address' record raised at least one error. Please review the errors error, also, on the end of process, I see the Error: 'RevisionID' cannot be empty.Address is not validated. error. The Save operation works fine when I assign a value to RevisionID field manually during the project debug.
As a solution, I tried to use the StackOverflow’s recommended way with Select instead of Update.
SOBillingAddress billAddress = docgraph.Billing_Address.Current = docgraph.Billing_Address.Select(new SOBillingAddress { OverrideAddress = true });
docgraph.Actions.PressSave();
But this is not the best way to select a value and save because in Select method we should add a field value and not a whole DAC or table.
The same history is with SOShippingAddress and SOShippingContact data. Similar topic is discussed here.
Is there a solution to satisfy the Acumatica’s native code?